Трудной темой для новичков в Астериск является подключения по протоколу Н.323. Напомню, что популярными драйверами каналов являются chan_h323 компании NuFone, его исходники заложены в исходниках Астериска в директории channels, и chan_ooh323 компании Objective Systems. Он идёт в составе Asterisk-addons.
Первый труден в компилляции, требует внешних библиотек openh323 & pwlib и компиллятора именно тех версий как указано в README - Open H.323 version v1.18.0, PWLib v1.10.0 and GCC v3.2.2. Отличается высокой устойчивостью.
Второй возможно покажется проще, для пользователей дистрибутивов TrixBox, Elastix - он поставляется уже готовым.
Для запуска любого из них нужно создать конфигурационный файл в /etc/asterisk - h323.conf в первом случае и ooh323.conf - во втором. Несмотря на кажущуюся похожесть есть существенные отличия в конфигурации обоих драйверов: первый требует точного указания ИП интерфейса, который будет использоваться для Н.323 соединений bindaddr=1.2.3.4 ; this SHALL contain a single, valid IP address for this machine
второй - допускает синтаксис bindaddr=0.0.0.0 ; The IP address, asterisk should listen on for incoming H323 connections Есть также существенные различия в описании пиров и Н323 алиасов для регистрации на гейткипере по протоколу RAS. Однако, всё очень подробно документировано с примерами в самих файлах конфигурации.
Чтобы собрать chan_h323 (на примере redhat систем - CentOS, Fedora, дистрибутивы TrixBox, PBX-ini-a-Flash, etc) необходимо:
Скачать Open H.323 v1.18.0, PWLib v1.10.0 в директорию /root # wget http://www.voxgratia.org/releases/openh323-v1_18_0-src-tar.gz # wget http://www.voxgratia.org/releases/pwlib-v1_10_0-src-tar.gz
Изменить # mv openh323-v1_18_0-src-tar.gz openh323-v1_18_0-src.tar.gz # mv pwlib-v1_10_0-src-tar.gz pwlib-v1_10_0-src.tar.gz и распаковать там же - # tar vfxz openh323-v1_18_0-src.tar.gz в директории /root/pwlib # tar vfxz pwlib-v1_10_0-src.tar.gz в директории /root/openh323
Далее - из инструкции README канала chan_h323: # cd /root/pwlib # ./configure # make clean opt # cd /root/openh323 # ./configure # make clean opt
В некоторых версиях Линукс отсутствуют необходимые заголовки компиллятора, сборка openh323 останавливается с ошибкой error: linux/compiler.h: No such file or directory Копируем /usr/src/kernel/2.6.18-128.1.10.el5-i686/includes/linux/compiler.h в /usr/include/linux и запускаем make clean opt снова.
Результат этих компиляций - динамические библиотеки /root/pwlib/lib/libpt_linux_x86_r.so.1.10.0 и /root/openh323/lib/libh323_linux_x86_r.so.1.18.0, которые лучше скопировать вместе с линками в директорию /lib
Скачать в директорию /usr/src соответствующие вашей текущей версии Астериск источники, например - wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.4.22.2.tar.gz и распаковать там же
# cd /usr/src/asterisk-1.4.22.2/ # export OPENH323DIR=/root/openh323/ # export PWLIBDIR=/root/pwlib/ # export OPENH323_LIBDIR=/lib # export PWLIB_LIBDIR=/lib # ./configure обратим внимание на строки - checking /root/openh323//../pwlib/version.h usability... yes checking /root/openh323//../pwlib/version.h presence... yes checking for /root/openh323//../pwlib/version.h... yes checking if PWLib version 1.10.0 is compatible with chan_h323... yes checking PWLib installation validity... yes checking /root/openh323//version.h usability... yes checking /root/openh323//version.h presence... yes checking for /root/openh323//version.h... yes checking if OpenH323 version 1.18.0 is compatible with chan_h323... yes checking OpenH323 build option... opt checking OpenH323 installation validity... yes
# make menuselect
тут может выпрыгнуть уведомление, что у вас отсутствует пакет ncurses, поэтому menuselect не запускается. Нужно скачать wget ftp://ftp.pbone.net/mirror/yum.trixbox.org/centos/5/RPMS-2.6.0.7/ncurses-devel-5.6-7.20070612.i386.rpm и установить rpm -ivh ncurses-devel-5.6-7.20070612.i386.rpm затем указать на библиотеку явным образом: nano menuselect/makeopts : NCURSES_LIB=/lib/libncurses.so.5.6
В меню можно не полениться, и выбрать в секции channels только нужный нам канал chan_h323 и убрать все остальные. То же проделать и в остальных секциях, так как нам не нужны для этой цели все остальные модули. Ну и
make Не пугайтесь, если увидите в процессе компилляции make[2]: Leaving directory `/usr/src/asterisk-1.4.22.2/channels/h323' ***************************************************************
********** Re-run 'make' to pick up H.323 parameters **********
*************************************************************** make[1]: *** [h323/libchanh323.a] Error 1 make[1]: Leaving directory `/usr/src/asterisk-1.4.22.2/channels' make: *** [channels] Error 2 Всё идёт как надо, просто делаем make ещё раз.
В текущей директории /usr/src/asterisk-1.4.22.2 таким образом будет собран весь Астериск, из которого нам нужно скопировать # cp /usr/src/asterisk-1.4.22.2/channels/chan_h323.so /usr/lib/asterisk/modules/ и установить права на него # chown asterisk:asterisk /usr/lib/asterisk/modules/chan_h323.so # chmod 640 /usr/lib/asterisk/modules/chan_h323.so и # cp /usr/src/asterisk-1.4.22.2/main/asterisk /usr/sbin Overwrite (y/n)? yes
теперь можно подправить конфигурацию, не забыть указать права # chown asterisk:asterisk /etc/asterisk/h323.conf и запустить модуль CLI>module load chan_h323.so Увидим - == Creating H.323 Endpoint == H.323 listener started Проверяем *CLI> show channeltypes Type Description Devicestate Indications Transfer ---------- ----------- ----------- ----------- -------- H323 The NuFone Network's Open H.323 Channel no yes no Zap Zapata Telephony Driver w/PRI no yes no Agent Call Agent Proxy Channel yes yes no Phone Standard Linux Telephony API Driver no yes no MGCP Media Gateway Control Protocol (MGCP) yes yes no Gtalk Gtalk Channel Driver no yes no Local Local Proxy Channel Driver yes yes no IAX2 Inter Asterisk eXchange Driver (Ver 2) yes yes yes SIP Session Initiation Protocol (SIP) yes yes yes ----------
h323.conf:
; The NuFone Network's ; Open H.323 driver configuration ; [general] port = 1720 ;bindaddr = 1.2.3.4 ; this SHALL contain a single, valid IP address for this machine ; ; See qos.tex or Quality of Service section of asterisk.pdf for a description of these parameters. ;tos_audio=ef ; Sets TOS for RTP audio packets. ;cos_audio=5 ; Sets 802.1p priority for RTP audio packets. ; ; You may specify a global default AMA flag for iaxtel calls. It must be ; one of 'default', 'omit', 'billing', or 'documentation'. These flags ; are used in the generation of call detail records. ; ;amaflags = default ; ; You may specify a default account for Call Detail Records in addition ; to specifying on a per-user basis ; ;accountcode=lss0101 ; ; You can fine tune codecs here using "allow" and "disallow" clauses ; with specific codecs. Use "all" to represent all formats. ; disallow=all ;allow=all ; turns on all installed codecs ;disallow=g723.1 ; Hm... Proprietary, don't use it... ;allow=gsm ; Always allow GSM, it's cool :) allow=alaw allow=ulaw ; see doc/rtp-packetization for framing options ; ; User-Input Mode (DTMF) ; ; valid entries are: rfc2833, inband, cisco, h245-signal ; default is rfc2833 ;dtmfmode=rfc2833 ; ; Default RTP Payload to send RFC2833 DTMF on. This is used to ; interoperate with broken gateways which cannot successfully ; negotiate a RFC2833 payload type in the TerminalCapabilitySet. ; To specify required payload type, put it after colon in dtmfmode ; option like ;dtmfmode=rfc2833:101 ; or ;dtmfmode=cisco:121 ; Set the gatekeeper ; DISCOVER - Find the Gk address using multicast ; DISABLE - Disable the use of a GK ; <IP address> or <Host name> - The acutal IP address or hostname of your GK ;gatekeeper = DISABLE ; ; ; Tell Asterisk whether or not to accept Gatekeeper ; routed calls or not. Normally this should always ; be set to yes, unless you want to have finer control ; over which users are allowed access to Asterisk. ; Default: YES ; ;AllowGKRouted = yes ; ; When the channel works without gatekeeper, there is possible to ; reject calls from anonymous (not listed in users) callers. ; Default is to allow anonymous calls. ; ;AcceptAnonymous = yes ; ; Optionally you can determine a user by Source IP versus its H.323 alias. ; Default behavour is to determine user by H.323 alias. ; ;UserByAlias=no ; ; Default context gets used in siutations where you are using ; the GK routed model or no type=user was found. This gives you ; the ability to either play an invalid message or to simply not ; use user authentication at all. ; ;context=default ; ; Use this option to help Cisco (or other) gateways to setup backward voice ; path to pass inband tones to calling user (see, for example, ; http://www.cisco.com/warp/public/788/voip/ringback.html) ; ; Add PROGRESS information element to SETUP message sent on outbound calls ; to notify about required backward voice path. Valid values are: ; 0 - don't add PROGRESS information element (default); ; 1 - call is not end-end ISDN, further call progress information can ; possibly be available in-band; ; 3 - origination address is non-ISDN (Cisco accepts this value only); ; 8 - in-band information or an appropriate pattern is now available; ;progress_setup = 3 ; ; Add PROGRESS information element (IE) to ALERT message sent on incoming ; calls to notify about required backwared voice path. Valid values are: ; 0 - don't add PROGRESS IE (default); ; 8 - in-band information or an appropriate pattern is now available; ;progress_alert = 8 ; ; Generate PROGRESS message when H.323 audio path has established to create ; backward audio path at other end of a call. ;progress_audio = yes ; ; Specify how to inject non-standard information into H.323 messages. When ; the channel receives messages with tunneled information, it automatically ; enables the same option for all further outgoing messages independedly on ; options has been set by the configuration. This behavior is required, for ; example, for Cisco CallManager when Q.SIG tunneling is enabled for a ; gateway where Asterisk lives. ; The option can be used multiple times, one option per line. ;tunneling=none ; Totally disable tunneling (default) ;tunneling=cisco ; Enable Cisco-specific tunneling ;tunneling=qsig ; Enable tunneling via Q.SIG messages ; ; Specify how to pass hold notification to remote party. Default is to ; use H.450.4 supplementary service message. ;hold=none ; Do not pass hold/retrieve notifications ;hold=notify ; Use H.225 NOTIFY message ;hold=q931only ; Use stripped H.225 NOTIFY message (Q.931 part ; ; only, usable for Cisco CallManager) ;hold=h450 ; Pass notification as H.450.4 supplementary ; ; service ; ;------------------------------ JITTER BUFFER CONFIGURATION -------------------------- ; jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a ; H323 channel. Defaults to "no". An enabled jitterbuffer will ; be used only if the sending side can create and the receiving ; side can not accept jitter. The H323 channel can accept jitter, ; thus an enabled jitterbuffer on the receive H323 side will only ; be used if the sending side can create jitter and jbforce is ; also set to yes.
; jbforce = no ; Forces the use of a jitterbuffer on the receive side of a H323 ; channel. Defaults to "no".
; jbmaxsize = 200 ; Max length of the jitterbuffer in milliseconds.
; jbresyncthreshold = 1000 ; Jump in the frame timestamps over which the jitterbuffer is ; resynchronized. Useful to improve the quality of the voice, with ; big jumps in/broken timestamps, usualy sent from exotic devices ; and programs. Defaults to 1000.
; jbimpl = fixed ; Jitterbuffer implementation, used on the receiving side of a H323 ; channel. Two implementations are currenlty available - "fixed" ; (with size always equals to jbmax-size) and "adaptive" (with ; variable size, actually the new jb of IAX2). Defaults to fixed.
; jblog = no ; Enables jitterbuffer frame logging. Defaults to "no". ;----------------------------------------------------------------------------------- ; ; H.323 Alias definitions ; ; Type 'h323' will register aliases to the endpoint ; and Gatekeeper, if there is one. ; ; Example: if someone calls time@your.asterisk.box.com ; Asterisk will send the call to the extension 'time' ; in the context default ; ; [default] ; exten => time,1,Answer ; exten => time,2,Playback,current-time ; ; Keyword's 'prefix' and 'e164' are only make sense when ; used with a gatekeeper. You can specify either a prefix ; or E.164 this endpoint is responsible for terminating. ; ; Example: The H.323 alias 'det-gw' will tell the gatekeeper ; to route any call with the prefix 1248 to this alias. Keyword ; e164 is used when you want to specifiy a full telephone ; number. So a call to the number 18102341212 would be ; routed to the H.323 alias 'time'. ; ;[time] ;type=h323 ;e164=18102341212 ;context=default ; ;[det-gw] ;type=h323 ;prefix=1248,1313 ;context=detroit ; ; ; Inbound H.323 calls from BillyBob would land in the incoming ; context with a maximum of 4 concurrent incoming calls ; ; ; Note: If keyword 'incominglimit' are omitted Asterisk will not ; enforce any maximum number of concurrent calls. ; ;[BillyBob] ;type=user ;host=192.168.1.1 ;context=incoming ;incominglimit=4 ;h245Tunneling=no ; ; Outbound H.323 call to Larry using SlowStart ; ;[Larry] ;type=peer ;host=192.168.2.1 ;fastStart=no
; Objective System's H323 Configuration example for Asterisk ; ooh323c driver configuration ; ; [general] section defines global parameters ; ; This is followed by profiles which can be of three types - user/peer/friend ; Name of the user profile should match with the h323id of the user device. ; For peer/friend profiles, host ip address must be provided as "dynamic" is ; not supported as of now. ; ; Syntax for specifying a H323 device in extensions.conf is ; For Registered peers/friends profiles: ; OOH323/name where name is the name of the peer/friend profile. ; ; For unregistered H.323 phones: ; OOH323/ip[:port] OR if gk is used OOH323/alias where alias can be any H323 ; alias ; ; For dialing into another asterisk peer at a specific exten ; OOH323/exten/peer OR OOH323/exten@ip ; ; Domain name resolution is not yet supported. ; ; When a H.323 user calls into asterisk, his H323ID is matched with the profile ; name and context is determined to route the call ; ; The channel driver will register all global aliases and aliases defined in ; peer profiles with the gatekeeper, if one exists. So, that when someone ; outside our pbx (non-user) calls an extension, gatekeeper will route that ; call to our asterisk box, from where it will be routed as per dial plan.
[general] ;Define the asterisk server h323 endpoint
;The port asterisk should listen for incoming H323 connections. ;Default - 1720 ;port=1720
;The IP address, asterisk should listen on for incoming H323 ;connections ;Default - 0.0.0.0: tries to find out local ip address on it's own bindaddr=0.0.0.0 ;Alias address for for asterisk server ;Default - "Asterisk PBX" h323id=ObjSysAsterisk e164=100
;CallerID for the asterisk originated calls ;Default - Same as h323id callerid=PostMet-Asterisk
;This parameter indicates whether channel driver should register with ;gatekeeper as a gateway or an endpoint. ;Default - no ;gateway=no
;Whether this asterisk server will use gatekeeper. ;Default - DISABLE ;gatekeeper = DISCOVER ;gatekeeper = a.b.c.d gatekeeper = DISABLE
;Whether asterisk should use fast-start and tunneling for H323 connections. ;Default - yes ;faststart=yes ;h245tunneling=yes
;Whether media wait for connect for fast start call ;Default - no ;mediawaitforconnect=no
;Location for H323 log file ;Default - /var/log/asterisk/h323_log ;logfile=/var/log/asterisk/h323_log
;Following values apply to all users/peers/friends defined below, unless ;overridden within their client definition
;Sets default context all clients will be placed in. ;Default - default context=default
;Sets rtptimeout for all clients, unless overridden ;Default - 60 seconds ;rtptimeout=60 ; Terminate call if 60 seconds of no RTP activity ; when we're not on hold
;Type of Service ;Default - none (lowdelay, thoughput, reliability, mincost, none) ;tos=lowdelay
;amaflags = default
;The account code used by default for all clients. ;accountcode=h3230101
;The codecs to be used for all clients.Only ulaw and gsm supported as of now. ;Default - ulaw ; ONLY ulaw, gsm, g729 and g7231 supported as of now disallow=all ;Note order of disallow/allow is important. ;allow=gsm allow=alaw allow=ulaw
; dtmf mode to be used by default for all clients. Supports rfc2833, q931keypad ; h245alphanumeric, h245signal. ;Default - rfc 2833 dtmfmode=rfc2833