DAHDI  - Digium Asterisk Hardware Device Interface

通常,我们得到的dahdi软件包包括dahdi-linux和dahdi-tool,分别是DAHDI的内核模块驱动和用户空间的工具。

1、DAHDI支持的硬件


    • 数字卡:
      • - wct4xxp:
        • * Digium TE205P/TE207P/TE210P/TE212P: PCI dual-port T1/E1/J1
        • * Digium TE405P/TE407P/TE410P/TE412P: PCI quad-port T1/E1/J1
        • * Digium TE220: PCI-Express dual-port T1/E1/J1
        • * Digium TE420: PCI-Express quad-port T1/E1/J1
      • - wcte12xp:
        • * Digium TE120P: PCI single-port T1/E1/J1
        • * Digium TE121: PCI-Express single-port T1/E1/J1
        • * Digium TE122: PCI single-port T1/E1/J1
      • - wcte11xp:
        • * Digium TE110P: PCI single-port T1/E1/J1
      • - wct1xxp:
        • * Digium T100P: PCI single-port T1
        • * Digium E100P: PCI single-port E1
      • - wcb4xxp:
        • * Digium B410: PCI quad-port BRI
      • - tor2: Tormenta quad-span T1/E1 card from the Zapata Telephony project
    • 模拟卡:
      • - wctdm24xxp:
        • * Digium TDM2400P/AEX2400: up to 24 analog ports
        • * Digium TDM800P/AEX800: up to 8 analog ports
        • * Digium TDM410P/AEX410: up to 4 analog ports
      • - wctdm:
        • * Digium TDM400P: up to 4 analog ports
      •  - xpp: Xorcom Astribank: a USB connected unit of up to 32 ports  (including the digital BRI and E1/T1 modules)
      • - wcfxo: X100P, similar and clones. A simple single-port FXO card

    • 其他驱动:
      • - pciradio: Zapata Telephony PCI Quad Radio Interface
      • - wctc4xxp: Digium hardware transcoder cards (also need dahdi_transcode)
      • - dahdi_dynamic_eth: TDM over Ethernet (TDMoE) driver. Requires dahdi_dynamic
      • - dahdi_dynamic_loc: Mirror a local span. Requires dahdi_dynamic
      • - dahdi_dummy: A dummy driver that only provides a DAHDI timing source.

2、安装


正常情况下,进入安装目录,直接make以及make install就可以:

安装DAHDI
cd dahdi-linux-xxxxx
make
make install
之后需要安装DAHDI tools
cd dahdi_tools-xxxxx
make
make install

注意:make过程中,每一步完成后,有可能会有其他提示,如提示你make config等,请照做!

安装完毕后,DAHDI即可正常工作。

3、模块的参数(Module Parameters)


内核模块可以通过模块参数来配置,通常在/etc/modprobe.d/或者是在文件/etc/modprobe.conf中用一行来配置。

如下:

options dahdi debug=1

同样,模块参数可以在系统运行时通过sys系统调用来更改

#cat /sys/module/dahdi/parameters/debug
0
#echo 1 > /sys/module/dahdi/parameters/debug
#cat /sys/module/dahdi/parameters/debug
1

有用的参数:

debug:
设置debug模式和debug级别,大多数模块可以被设置成0(禁止debug)和其他的数值(使能debug)
大多数模块有称作debugging flags的bit位,用来控制不同的调试信息,具体如下:
  • - dahdi_dummy:
* 1: DEBUG_GENERAL - general error messages.
* 2: DEBUG_TICKS - Show that the module is alive :-)- wctdm24xxp:
* 1: DEBUG_CARD
* 2: DEBUG_ECHOCAN
  • - wct4xxp:
* 1: DEBUG_MAIN
* 2: DEBUG_DTMF
* 4: DEBUG_REGS
* 8: DEBUG_TSI
* 16: DEBUG_ECHOCAN
* 32: DEBUG_RBS
* 64: DEBUG_FRAMER
  • - xpp: See also README.Astribank:
* 1: GENERAL - General debug comments.
* 2: PCM - PCM-related messages. Tend to flood logs.
* 4: LEDS - Anything related to the LEDs status control. The driver

produces a lot of messages when the option is enabled.

* 8: SYNC - Synchronization related messages.
* 16: SIGNAL - DAHDI signalling related messages.
* 32: PROC - Messages related to the procfs interface.
* 64: REGS - Reading and writing to chip registers. Tends to flood
logs.
* 128: DEVICES - Device instantiation, destruction and such.
* 256 - COMMANDS - Protocol commands. Tends to flood logs.
deftabs:
回音消除的默认级别。
注意:asterisk的chan_dahdi总会试着传递它自己的值,可能是另一个默认值。因此如果只在这里更改,有可能会不起作用。

得到一个模块支持的参数的列表,使用下面的命令:
modinfo modname
或者是你刚刚编译的模块
modinfo ./modname
对xpp模块来说,你还可以得到参数的描述和默认值。另外,还可以在README.astribank中看到关于xpp的有用参数的列表。

4、DAHDI的设备文件


用户空间的程序通常通过位于/dev/dahdi目录下的设备文件和DAHDI交互。设备文件可以静态的或动态的产生。具体描述如下:

* /dev/dahdi/ctl (196:0) - a general device file for various information and
control operations on the DAHDI channels.
* /dev/dahdi/NNN (196:NNN) - for NNN in the range 1-249. A device file for
DAHDI channel NNN. It can be used to read data from the channel
and write data to the channel.
* /dev/dahdi/transcode (196:250) - Used to connect to a DAHDI transcoding
device.
* /dev/dahdi/timer (196:253) - Allows setting timers. Used anywhere?
* /dev/dahdi/channel (196:254) - Can be used to open an arbitrary DAHDI
channel. This is an alternative to /dev/dahdi/NNN that is not limited to
249 channels.
* /dev/dahdi/pseudo (196:255) - A timing-only device. Every time you open
it, a new DAHDI channel is created. That DAHDI channel is "pseudo" -
DAHDI receives no data in it, and only sends garbage data with the
same timing as the DAHDI timing master device.

5、DAHDI Timing


PBX系统通常需要单一的时钟,假如你通过数字接口(T1或E1)连接到电话供应商,通常是由电话供应商提供(由接口提供时钟)。因此,对asterisk来说,一个重要的任务是向PBX提供时钟。DAHDI每个tick为1ms,在一个tick中,从每一个活动的DAHDI通道上读取1byte的数据。Asterisk通过一个打开的pseudo通道,可以把tick作为时钟。不过,并不是所有的PBX系统都连接到T1以及类似的接口。使用模拟接口的话,并不需要和其他的部分同步。再说,其他的系统可能连DAHDI硬件都没有。就算是一个数字卡,也有可能不连接到供应商接口而作为其他功能使用。DAHDI系统同样具备通过卡上的clock提供时钟。如果以上都不能使用,你可以通过dahdi_dummy单独的提供时钟,而不需要任何的DAHDI硬件设备。这在大多数的系统和内核上都能工作。

6、spans和channels


DAHDI向用户空间程序提供电话channel,这和DAHDI中逻辑上的定义span相关。对数字电话适配器(T1或E1)来说,一个span代表一个单个的端口。对模拟系统来说,一个span代表一个PCI适配器或者一个相似的逻辑单元。channel和span都是通过enum结构表示(从1开始),当生常channel或者span号时,从最小没有使用的那个号开始。

7、PROCFS接口:/proc/dahdi


从/proc/dahdi可以得到当前spans的列表,以及一个sapn中的channel数目。如下所示:

Span 1: XBUS-00/XPD-00 "Xorcom XPD #0/0: FXS"
2 XPP_FXS/0/0/1 FXOLS (In use)

其中标题行包括span的名称、span号以及任何的alarm标识(可选)
channel行包括channel号、名称以及实际分配的信号,同时还包括是否正在使用等。

8、ABI接口


向应用层提供的接口,这里暂不了解

9、alarm类型


alarm用来指示由于某种原因,该端口无法工作。暂不具体说明了。


摘自
http://hi.baidu.com/vim_li/blog/item/dc83b81435face4121a4e93b.html