• No se han encontrado resultados

FAX con IAXmodem y Hylafa

In document Manual Asterisk Avanzado (página 34-44)

Vamos a empezar. Primero instalamos las librerías libtiff y libtool

yum install libtiff libtiff-devel libtool

IAXmodem

IAXmodem es un modem software, escrito en C que utiliza un canal IAX (uno de los protocolos presentes en Asterisk) en lugar de una línea telefónica y utiliza un DSP por software en lugar de un chip DSP (Digital Signal Processing).

Descargamos las fuentes de iaxmodem:

cd /usr/src wget http://switch.dl.sourceforge.net/sourceforge/iaxmodem/iaxmodem-1.2.0.tar.gz Descomprimimos el paquete tar -zxvf iaxmodem-1.2.0.tar.gz Entramos en la carpeta: cd iaxmodem-1.2.0 y compilamos: ./configure make

Copiamos el programa en la siguiente carpeta:

cp iaxmodem /usr/local/sbin

Creamos algunas carpetas indispensables para que IAXmodem funcione:

mkdir /etc/iaxmodem

mkdir /var/log/iaxmodem

touch /var/log/iaxmodem/ttyIAX0

touch /var/log/iaxmodem/iaxmodem

Modificamos el archivo de configuración predefinido presente con las fuentes:

vi iaxmodem-cfg.ttyIAX

Esta es la configuración con la cual funciona bien: device /dev/ttyIAX owner uucp:uucp mode 660 port 4570 refresh 300 server 127.0.0.1 peername iaxmodem secret password cidname VozToVoice cidnumber XXXXXXXXXX codec ulaw

Esta configuración es valida si tenemos instalado IAXmodem (más que aconsejado) en el mismo computador donde está Asterisk. En el caso de dos computadores distintos tendrán que indicar en la línea server la dirección IP del servidor Asterisk. Pongan su contraseña en secret y en cidname y cidnumber nombre y número telefónico que usará IAXmodem para presentarse a Asterisk.

Podemos configurar cuantos IAXmodem queramos cambiando en la primera línea el nombre del device y creando un archivo separado para cada uno. Ejemplo: ttyIAX2 ttyIAX3, etc…

Guardamos las modificaciones y seguimos copiando el archivo en la carpeta /etc/iaxmodem que hemos creado:

Ahora modificamos la configuración de asterisk para insertar la nueva troncal IAX: Vi /etc/asterisk/iax.conf [general] disallow=all allow=ulaw allow=g729 allow=gsm bindport=4569 bindaddr=0.0.0.0 language=es srvlookup=yes [iaxmodem] type=friend context=fax disallow=all allow=ulaw username=iaxmodem secret=password qualify=yes notransfer=yes host=dynamic

Guardamos las modificaciones y actualizamos la configuración de asterisk entrando en la consola::

asterisk –r

Escribimos:

CLI> iax2 relaod

CLI> quit

Ahora podemos hacer una prueba para ver si la conexión entre IAXmodem y Asterisk funciona:

cd /usr/local/sbin ./iaxmodem ttyIAX

Debería aparecer:

[2009-06-08 12:03:39] Modem started

[2009-06-08 12:03:39] Setting device = '/dev/ttyIAX' [2009-06-08 12:03:39] Setting owner = 'uucp:uucp' [2009-06-08 12:03:39] Setting mode = '660'

[2009-06-08 12:03:39] Setting port = 4570 [2009-06-08 12:03:39] Setting refresh = 300

[2009-06-08 12:03:39] Setting server = '127.0.0.1' [2009-06-08 12:03:39] Setting peername = 'iaxmodem' [2009-06-08 12:03:39] Setting secret = 'password' [2009-06-08 12:03:39] Setting cidname = 'VozToVoice’ [2009-06-08 12:03:39] Setting cidnumber = 'XXXXXXXXX' [2009-06-08 12:03:39] Setting codec = ulaw

[2009-06-08 12:03:39] Opened pty, slave device: /dev/pts/4 [2009-06-08 12:03:39] Created /dev/ttyIAX symbolic link

Per pararlo presionamos CTRL-C

[2009-06-08 12:03:45] Terminating on signal 2...

Antes de hacerlo controlamos que en la consola de Asterisk aparezca la conexión de IAXmodem (en otra ventana Terminal)

Listo. Ya tenemos parte del “problema” solucionado.

Ahora instalamos el script presente en la carpeta de las fuentes de IAXmodem para que éste arranque al boot de Linux:

cd /usr/src/cd iaxmodem-1.2.0

mv iaxmodem.init.fedora /etc/init.d/iaxmodem

Lo volvemos ejecutable:

chmod +x /etc/init.d/iaxmodem

Lo configuramos para el arranque automático:

chkconfig --add iaxmodem chkconfig iaxmodem on

lo ponemos a “trabajar”:

/etc/init.d/iaxmodem start

Hylafax

Empecemos con Hylafax

Antes que nada instalamos algunos paquetes (dependencias) requeridas por Hylafax:

yum install ghostscript ghostscript-devel sharutils ghostscript-fonts

En la página de Hylafax están presentes los paquetes para las distintas distribuciones de Linux:

Descargamos el paquete para Centos:

wget http://yum.trixbox.org/centos/5/RPMS/hylafax-4.4.4-1rhel5.i386.rpm

Lo instalamos:

rpm -ivh hylafax-4.4.4-1rhel5.i386.rpm

Añadimos el faxgetty al inittab (faxgetty es el programa que realmente contesta las llamadas)

Vi /etc/inittab

Añadimos esta línea:

Guardamos los cambios y volvemos a arrancar inittab:

init q

Ahora podemos empezar con la configuración de Hylafax (un poco larga pero necesaria). Presten particular atención a las partes en negrita:

faxsetup

Update /var/spool/hylafax/status/any.info.

HylaFAX configuration parameters are:

[1] Init script starts faxq: yes

[2] Init script starts hfaxd yes

[3] Start old protocol: no

[4] Start paging protocol: no

Are these ok [yes]?

Contestamos yes

Modem support functions written to /var/spool/hylafax/etc/setup.modem.

Configuration parameters written to /var/spool/hylafax/etc/setup.cache.

No scheduler config file exists, creating one from scratch.

Country code [1]? 57

Area code []? 1

Long distance dialing prefix [1]? 0

International dialing prefix [011]? 00

Dial string rules file (relative to /var/spool/hylafax) ["etc/dialrules"]?

Tracing during normal server operation [1]?

Default tracing during send and receive sessions [0xffffffff]?

Continuation cover page (relative to /var/spool/hylafax) []?

Timeout when converting PostScript documents (secs) [180]?

Maximum number of concurrent jobs to a destination [1]?

Define a group of modems []?

Time of day restrictions for outbound jobs ["Any"]?

Pathname of destination controls file (relative to /var/spool/hylafax) []?

Timeout before purging a stale UUCP lock file (secs) [30]?

Max number of pages to permit in an outbound job [0xffffffff]?

The non-default scheduler parameters are:

CountryCode: 57

AreaCode: 1

LongDistancePrefix: 0

InternationalPrefix: 00

Are these ok [yes]? yes

Creating new configuration file /var/spool/hylafax/etc/config...

Restarting HylaFAX server processes.

Should I restart the HylaFAX server processes [yes]?

/etc/rc.d/init.d/hylafax start

Starting HylaFAX queue manager (faxq): [ OK ]

Starting HylaFAX server (hfaxd): [ OK ]

Restarting HylaFAX modem manager (faxgetty): [ OK ]

Do you want to run faxaddmodem to configure a modem [yes]?

Serial port that modem is connected to []? ttyIAX

Ok, time to setup a configuration file for the modem. The manual

page config(5F) may be useful during this process. Also be aware

that at any time you can safely interrupt this procedure.

Reading scheduler config file /var/spool/hylafax/etc/config.

No existing configuration, let's do this from scratch.

Country code [1]? 57

Area code [415]? 1

Phone number of fax modem [+1.999.555.1212]? +571XXXXXXXX

Local identification string (for TSI/CIG) ["NothingSetup"]?

Long distance dialing prefix [1]? 0

International dialing prefix [011]? 00

Dial string rules file (relative to /var/spool/hylafax) [etc/dialrules]?

Tracing during normal server operation [1]?

Tracing during send and receive sessions [11]?

Protection mode for received facsimile [0600]?

Protection mode for session logs [0600]?

Rings to wait before answering [1]? 2

Modem speaker volume [off]?

Command line arguments to getty program ["-h %l dx_%s"]?

Pathname of TSI access control list file (relative to /var/spool/hylafax) [""]?

Pathname of Caller-ID access control list file (relative to /var/spool/hylafax) [""]?

Tag line font file (relative to /var/spool/hylafax) [etc/lutRS18.pcf]?

Tag line format string ["From %%l|%c|Page %%P of %%T"]?

Time before purging a stale UUCP lock file (secs) [30]?

Hold UUCP lockfile during inbound data calls [Yes]?

Hold UUCP lockfile during inbound voice calls [Yes]?

Percent good lines to accept during copy quality checking [95]?

Max consecutive bad lines to accept during copy quality checking [5]?

Max number of pages to accept in a received facsimile [25]?

Syslog facility name for ServerTracing messages [daemon]?

Set UID to 0 to manipulate CLOCAL [""]?

Use available priority job scheduling mechanism [""]?

CountryCode: 57 AreaCode: 1 FAXNumber: +571XXXXXXXX LongDistancePrefix: 0 InternationalPrefix: 00 DialStringRules: etc/dialrules SessionTracing: 11 RingsBeforeAnswer: 2 SpeakerVolume: off GettyArgs: "-h %l dx_%s" LocalIdentifier: "NothingSetup" TagLineFont: etc/lutRS18.pcf

TagLineFormat: "From %%l|%c|Page %%P of %%T"

Are these ok [yes]?

Now we are going to probe the tty port to figure out the type

of modem that is attached. This takes a few seconds, so be patient.

Note that if you do not have the modem cabled to the port, or the

modem is turned off, this may hang (just go and cable up the modem

or turn it on, or whatever).

Probing for best speed to talk to modem: 38400 OK.

About fax classes:

The difference between fax classes has to do with how HylaFAX interacts

with the modem and the fax protocol features that are used when sending

or receiving faxes. One class isn't inherently better than another;

however, one probably will suit a user's needs better than others.

Class 1 relies on HylaFAX to perform the bulk of the fax protocol.

Class 2 relies on the modem to perform the bulk of the fax protocol.

Class 2.0 is similar to Class 2 but may include more features.

Class 1.0 is similar to Class 1 but may add V.34-fax capability.

Class 2.1 is similar to Class 2.0 but adds V.34-fax capability.

HylaFAX generally will have more features when using Class 1/1.0 than

when using most modems' Class 2 or Class 2.0 implementations. Generally

any problems encountered in Class 1/1.0 can be resolved by modifications

to HylaFAX, but usually any problems encountered in Class 2/2.0/2.1 will

require the modem manufacturer to resolve it.

Use Class 1 unless you have a good reason not to.

This modem looks to have support for Class 1 and 1.0.

How should it be configured [1]?

Hmm, this looks like a Class 1 modem.

Product code (ATI0) is "spandsp".

Other information (ATI3) is "www.soft-switch.org".

DTE-DCE flow control scheme [default]?

Modem manufacturer is "spandsp".

Using prototype configuration file iaxmodem...

The modem configuration parameters are:

ModemResetCmds: "ATH1\nAT+VCID=1"

Are these ok [yes]?

Creating new configuration file /var/spool/hylafax/etc/config.ttyIAX...

Done setting up the modem configuration.

Checking /var/spool/hylafax/etc/config for consistency...

...some parameters are different.

The non-default scheduler parameters are:

CountryCode: 57

AreaCode: 1

LongDistancePrefix: 0

InternationalPrefix: 00

DialStringRules: etc/dialrules

Are these ok [yes]?

Creating new configuration file /var/spool/hylafax/etc/config...

...saving current file as /var/spool/hylafax/etc/config.sav.

Don't forget to run faxmodem(8C) (if you have a send-only environment)

or configure init to run faxgetty on ttyIAX.

Do you want to run faxaddmodem to configure another modem [yes]? no

Looks like you have some faxgetty processes running (PIDs are):

13236

It is usually a good idea to restart these processes after running

faxsetup; especially if have just installed new software. If these

processes are being started by init(8C) then sending each of them a

QUIT message with the faxquit command should cause them to be restarted.

Is it ok to send a QUIT command to each process [yes]?

/etc/init.d/hylafax restart

Shutting down HylaFAX queue manager (faxq): [ OK ]

Shutting down HylaFAX server (hfaxd): [ OK ]

Starting HylaFAX queue manager (faxq): [ OK ]

Starting HylaFAX server (hfaxd): [ OK ]

Restarting HylaFAX modem manager (faxgetty): [ OK ]

Todos los archivos de configuración que se crearan a lo largo del proceso de seteo de Hylafax los encontraremos en la carpeta /var/spool/hylafax/etc y en cualquier momento (si tenemos problemas) lo podemos modificar.

Prueba

Editamos el archivo extensions.conf y agregamos lo siguiente.

[from-pstn]

exten => s,1,Answer

exten => s,2,Dial(IAX/iaxmodem)

He guardado los cambios y reiniciado Asterisk

/etc/init.d/asterisk restart

FaxMaster el usuario predefinido que Hylafax usa para enviar el fax al correo electrónico. Si quieren pueden cambiarlo modificando el archivo FaxDispatch que encuentran en la carpeta /var/spool/hylafax/etc

Si quieren recibir el mensaje con el texto en español siempre en el mismo archivo añaden esta línea:

TEMPLATE=es

Para el envío de los faxes:

Crear en extension.conf un contexto [fax] (El mismo que hemos configurado para la troncal iaxmodem en iax.conf) con las siguientes líneas:

[fax]

exten => _X.,1,Dial(ZAP/g0/${EXTEN})

exten => _X.,n,Hangup

Actualizan el dialplan:

/etc/init.d/asterisk reload

Desde el terminal de Linux escriben:

sendfax -n -d <faxnumber> <file.txt>

Ejemplo:

sendfax –n –d 4834000 /tmp/documento.pdf

que es todo.

In document Manual Asterisk Avanzado (página 34-44)

Documento similar