n'guild Wed 08 Sep, 2010 [08:19 UTC]
Menu

Asteriko,en

Translate of the documentation about Asteriko
Services > Telephony
print


The asteriko aim is to allow users to automatically create configuration files, without requiring technical skills. The asteriko solution stores in the databases the informations about users, groups, trunks... and create the required config files using cron automated task.

The project is composed in two parts. The first one is in charge of GUI -> DB and the other DB-> config files.


Configuration Files


It's obvious the configuration file part that forced us to do the choice of a templates of operations and organisations about various users in this configuration files.
In this document, we will only deal first about configuration files concerning IAX, EXTENSIONS and VOICEMAIL which are making, for moment, a good basis to start the project.

File IAX.CONF


Protocol's parameters definition


A first part is to define protocol : Port, Ip, Jitter

[general]
bindaddr=0.0.0.0
bandwidth=low
echocancel=yes
jitterbuffer=yes
maxjitterbuffer=500
maxexcessbuffer=100
dropcount=3
tos=lowdelay
mailboxdetail=yes
language=fr
disallow=all
allow=gsm



Nb: The section above needs to be optimized on the jitterbuffer. Tests and measurements can be necessary.

Users Definition


After the protocol parameters, we can then consider the definition of the users allowed to connect to Asterisk server. Two types of peers can be used
  • the standard user
  • the Asterisk server

For users, sections could be like the following on eqch asterisk box


[MyServerName]
type=friend
host=dynamic
secret=MyPassword


Nb: For peers with static IP, instead of an IP address the 'host' field can be filled with the domain name.

For stardard user
It is now compulsory that users use numbers rather than names, to ease the reading of extensions.conf file.

The section must look like the following :

[ExtensionNumber]
type=friend
host=dynamic
secret=MyPassword
context=Internationnal
callerid => ""MyFirstName MyLastName" <ExtensionNumber>
mailbox=ExtensionNumber


Nb: With IAX, it's not possible to define more than one 'context'. However, including 'context' in other 'contexts' allows to define very clearly the discrimination or, in other words, the users rights on dialplan access.

The example above allows the user, according to his discrimination, to terminate calls in the countries belonging to the internationnal 'context'. A list of 'context' and groups of 'contexts' have to be define to give access to users or to a particular country or country group. (Europe, Asia, Fixe Europe, Mobil Europe, Fixe France, Mobile France...) or worldwide (like above example).

protect user against anonymous login

For security reasons, you must declare a 'guest' user. This operation allows to reject the logins without username or without password. This user shouldn't be associate by another definite context in extensions.conf.


[guest]
type=user
host=dynamic


File VOICEMAIL.CONF


Voicemail's bahavior definition


Like in IAX.CONF, the general section can be setup to allow administrators to customize the voicemail parameters (sending, body of message) and even, recording timings, voicemail contents...

[general]
; Default formats for writing Voicemail
;format=g723sf|wav49|wav
format=wav49|gsm|wav

fromstring=amnesia
serveremail=amnesia@no-log.org

; Should the email contain the voicemail as an attachment
attach=yes
; Maximum length of a voicemail message in seconds
;maxmessage=180
; Maximum length of greetings in seconds
;maxgreet=60
; How many miliseconds to skip forward/back when rew/ff in message playback
skipms=2000
; How many seconds of silence before we end the recording
maxsilence=10

; Silence threshold (what we consider silence, the lower, the more sensitive)
silencethreshold=128
; Max number of failed login attempts
maxlogins=3
envelope=no

;Body

emailbody=Yo ${VM_NAME}:\n\n
A little love message from amnesia just to avoid it to forget...\n\n
The message is ${VM_DUR}(numéro ${VM_MSGNUM}) minutes long in mailbox ${VM_MAILBOX} and comes
from ${VM_CALLERID}, on ${VM_DATE}. Take time to have a look on it.\n\n
signed... I already forgot :-)\n

;
; You can override the default program to send e-mail if you wish, too
;
;mailcmd=/usr/sbin/sendmail -t
;
; Users may be located in different timezones, or may have different
; message announcements for their introductory message when they enter
; the voicemail system. Set the message and the timezone each user
; hears here. Set the user into one of these zones with the tz= attribute




Nb: This configuration file is the one running on amnesia.


Time shifts definition


[zonemessages]
eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H 'digits/hundred' M 'hours'



Nb: This section presents the only place on all configurations file of Asterisk where we can associate time shifts to a user. This following lines define the TimeZones. These Timezone are usually not used by the section, whereas it's not the case in this example.

Users definition


[default]
MyEntension => MyPassword,MyName, MySurname,MyAdress@MyDomain.xx


Very simple, except maybe the configuration of TimeZone which it's not so simple.


File EXTENSIONS.CONF



This file is in charg of routing rules and discrimination. In our case, each number belong a 'context' (internal, national...) to allow a specific user to access to phone numbers.


General file Configuration



[general]
static=yes
writeprotect=no


This options allow to limit access at configuration files. You must leave this options with its default values.

The call routing macro for users


[macro-stdexten]
;
; Standard extension macro:
;${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as well
;${ARG2} - Device(s) to ring IAX
;
exten => s,1,SetMusicOnHold(default)
exten => s,2,Dial(${ARG2},10) ; Ring the interface, 10 seconds maximum
exten => s,3,Voicemail(u${ARG1}) ; If unavailable, send to voicemail w/ unavail announce
exten => s,5,Hangup ; Hang them up.
exten => s,103,Voicemail(b${ARG1}) ; If busy, send to voicemail w/ busy announce
exten => s,104,Hangup ; Hang them up.


This macro is used to try to reach an extension ${ARG1} and, if no answer or busy is detected, the call is routed to the user voicemail.

Services Context


In our case, all services are gathered in two contexts [test-services] and [user-services]. If, in future use, we want to dissociate each service to allow their access according to a specific discrimination, we will need to split them into other 'contexts' and avoid including them in each others.

This is also the 'context' used for IVR (Interactiv Voice Routing) script used to wellcome users or cutomers not registred on any channel like IAX or SIP (a good example is a call comming from a ZAP interface). An acces to normaly registred users but comming throught a ZAP channel must be done. The user must be able to identify by typing a login and password to get acces to his usual 'contexts' or discrimination.

[tests-services]

;
; Create an extension, 600, for dialing the
; Asterisk demo.
;

exten => 600,1,Playback(demo-abouttotry); Let them know what's going on
exten => 600,2,Dial(IAX2/guest@misery.digium.com/s@default) ; Call the Asterisk demo
exten => 600,3,Playback(demo-nogo) ; Couldn't connect to the demo site
exten => 600,4,Goto(s,6) ; Return to the start over message.

;
; Create an extension, 601, for evaluating echo latency.
;
exten => 601,1,Playback(demo-echotest) ; Let them know what's going on
exten => 601,2,Echo ; Do the echo test
exten => 601,3,Playback(demo-echodone) ; Let them know it's over
exten => 601,4,Goto(s,6) ; Start over

[user-services]
;
; Give voicemail at extension 700
;
exten => 700,1,VoicemailMain
exten => 700,2,Hangup

;
; Or a conference room (you'll need to edit meetme.conf to enable this room)
;
exten => 800,1,MeetMeCount(1234)
exten => 800,2,Meetme,1234


A 'context' is also required to provide an access to all the services without being obliged to define all of them one by one.

[All-Services]
include => user-services
include => tests-services


Inbound calls 'context'


This part of the job is not done yet and must be define to ease th creating of routing scripts without any telephony knowledge. But one thing is sure, this 'context' is dedicated to nbound calls comming from ZAP or H323 channels. In our case it is restricted to services accesses. For security purposes, it not possible for the user to access the full dialplan without any authentication. This 'context' consider that the caller knows there's a IVR behind the Asterisk box and is waiting for 4 second a user input if the user don't type anything it will look like a standard answering ;achine except that the system will first try to transver the call to a specific user of the dialplan. This way if the user is registred on the Asterisk box (no matter where he is) the call will be transfer to him.

[menu]
include => All-Services

exten => s,1,Wait,15
exten => s,2,Answer
exten => s,3,DigitTimeout,2 ; Set Digit Timeout to 5 seconds
exten => s,4,ResponseTimeout,4 ; Set Response Timeout to 10 seconds

exten => #,1,Dial(IAX2/MyIaxUser:MyIaxPassword@MyDomainName/MyExtension@MyContext) ;Used to ring a specific extension if no key is pressed by the user

exten => t,1,Goto(#,1) ; If they take too long goto to previous line to route call to any extension
exten => i,1,Playback(invalid) ; "That's not valid, try again"

exten => _XXX,1,Dial(IAX2/${EXTEN}@All-Services)

[menu-SVI]
exten => s,1,Wait,15
exten => s,2,Answer
exten => s,3,DigitTimeout,2 ; Set Digit Timeout to 5 seconds
exten => s,4,ResponseTimeout,4 ; Set Response Timeout to 10 seconds
exten => s,5,BackGround(IVR_VoiceGuide)

exten => 1,1,Goto($SVI1,1) ;If key 1 is pressed go to extension SVI1
exten => 2,1,Goto($SVI2,1) ;If key 1 is pressed go to extension SVI2
exten => 3,1,Goto($SVI3,1) ;If key 1 is pressed go to extension SVI3

exten => t,1,Goto(s,5) ; If they take too long goto to previous line to route call to any extension
exten => i,1,Playback(invalid) ; "That's not valid, try again"


The standard user 'context' [Internal]


[Internal]

exten => _5XX,1,GotoIf($"${EXTEN}" = "506"?MyContext,MyExtension,1)
exten => _5XX,2,Playback(transfer,skip)
exten => _5XX,3,Macro(stdexten,${EXTEN},IAX2/${EXTEN})
include => All-Services


Nb: In this example we consider that all the users are only registred using IAX and present in IAX.CONF file. Each IAX user must be declared as a number starting by the digit '5' and using only 3 digits. User 506 also asked to transfer all of his calls to a specific number in a specific 'context'. For other protocols than IAX, it is possible to extend this rule by defining different ranges of numbers according the protocol. For example 5XX for IAX and 4XX for SIP and why not 3XX for H323.

The international 'context' known as [Internationnal]


The pre-requisit in iax.conf file was that each user belongs to one on more 'contexts'. In our case all international destinations are organized in continents, then in countries and finally into Asterisk boxes of each country.

;Context including every continents
[Internationnal]
include => Internal
include => Europe
include => Asia
include => Usa
include => Africa
include => Russia

;Context including every Europeen coumtries where Asterisk boxes are known.
[Europe]
include => Internal
include => France
include => UK
include => Italy
include => Germany
include => Spain

;Context including Asterisk boxes located in France
[France]
include => Internal

;Loïc Asterisk server on ZapTel adapter reachable by 0033 between 00h00 and 04h00. The loic' server is registred so we can use the name used for the registration instead the domain name.
exten => _00033.,1,GotoIfTime(00:00-4:00|mon-fri|*|*?France,${EXTEN},3)
;Wait 5 secondes to get an acknowledge from the remote site.
exten => _00033.,2,Dial(IAX2/user:password@IaxRegistredName/${EXTEN}@France,5)

;If Loïc is not reachable after 5 seconds try Tom's Asterisk box on ZapTel adapter reachable by 0033 between 00h00 and 04h00. The Tom's server is not registred so we must use the domain name.
exten => _00033.,3,GotoIfTime(00:00-4:00|mon-fri|*|*?France,${EXTEN},5)
;Wait 5 secondes to get an acknowledge from the remote site.
exten => _00033.,4,Dial(IAX2/user:password@domaine2.fr/${EXTEN}@France,5)

;If Tom is not reachable after 5 seconds try Mose's Asterisk box on ZapTel adapter reachable by 0033 between 00h00 and 04h00. The Mose's server is not registred so we must use the domain name.
exten => _00033.,5,GotoIfTime(00:00-4:00|mon-fri|*|*?France,${EXTEN},7)
;Wait 5 secondes to get an acknowledge from the remote site.
exten => _00033.,6,Dial(IAX2/user:password@domaine3.fr/${EXTEN}@France,5)

;If none of these servers are reachable let's play a congestion tone.
exten => _00033.,7,Answer
exten => _00033.,8,Playtones(congestion)
exten => _00033.,9,Wait(5)
exten => _00033.,10,StopPlaytones
exten => _00033.,11,Hangup

;Local extensions' definition for Loïc site reachable from Amnesia Dialplan
;To make it work, Loïc needs to declare his extensions in the 'France' 'context'and must start with digit '1' followed by 3 more digits and Tom must declare extension starting with digit '3' followed by 3 more digits.
exten => _331XXX,1,Dial(IAX2/user:password@domaine1.fr/${EXTEN:2}@France)
exten => _333XXX,1,Dial(IAX2/user:password@domaine2.fr/${EXTEN:2}@France)

;If none of these servers are reachable let's play a congestion tone.
exten => t,1,Answer
exten => t,2,Playtones(congestion)
exten => t,3,Wait(5)
exten => t,4,StopPlaytones
exten => t,5,Hangup

[UK]
include => Internal
;Damian Asterisk server
exten => _00044.,3,Dial(IAX2/user:password@domaine.co.uk/${EXTEN}@default)
;To make it work, Damian needs to declare his extensions in the 'default' 'context'and must start with digit '2' followed by 3 more digits.

exten => _2XXX,1,Dial(IAX2/user:password@domaine.co.uk/${EXTEN}@default)


Calls redirection on servers located in a LAN using NAT


The previous routing example between peers for loïc, tom and mose shows different ways of proceding to call routing. Loïc uses NAT in his LAN with both Asterisk server and IAX client.
The thing you have to know is IAX take the default port (if not precised in iax.conf, it is 4569) for the first client or server. Then if a second client or server is started it could use the 14569.
Imagine you have set you router to forward packets on UDP 4569 from your public IP to your Asterisk box. So what appends if your Asterisk box starts after your IAX client?
In this specific case don't use port forwarding on your router but register your asterisk box to the remote site this way it will be reachable from known hosts and your IAX client and asterisk box can start in the order you want.
If you want external clients to reach your Asterisk box define a specific port in your iax.conf file, set the port forwarding for this port on your router and ask your client to use an alternate port.
If it's not possible, be very carefull to start the Asterisk box before any client in your LAN.

Including order with 'contexts'


The order you use to include your 'contexts' is very important. Indeed, mainly in overflow rules it is compulsory to keep a specific order to be sure that two matching paterns in contexts will be taken in the right order.

In our case use the following order:

[macro-stdexten]
[Internationnal]
[Europe]
[France]
[UK]


Add then the European countries in the same order than the one defined in the [Europe] 'context'.

[Asia]
Add then the other continents in the same order as the [Internationnal] 'context'

[Internal]

[All-Services]

[tests-services]

[user-services]

ZAPATA.CONF file


[trunkgroups]

[channels]
language=fr
context=menu ;Defined in extensions.conf
rxwink=300

usedistinctiveringdetection=no
usecallerid=no
hidecallerid=yes
callwaiting=yes

usecallingpres=no
callwaitingcallerid=no

threewaycalling=yes
transfer=yes
cancallforward=yes
callreturn=yes

echocancel=yes
echocancelwhenbridged=yes

rxgain=0.0
txgain=0.0

group=1
callgroup=1
pickupgroup=1

immediate=no
amaflags=billing

busydetect=yes
busycount=4

callprogress=no
progzone=fr

signalling=fxs_ks
context=menu
channel => 1


Asteriko Database


The database structure is deeply linked to the file format but tend to ease the end user comprehension. This is why many informatins have been placed in the same table.

Relashonship scheme


The database relashonship scheme will be like the following. Each table is then more precisely defines in the next sections.

Warning: The following drawing is not up to date due to quick evolution in the begining of the project so prefer looking at the tables structures witch should be more close to reality.



Table "ast_uers"


Table's Definiton

This table is the main table of the Asteriko's relationship sheme.

ast_users
Field NameField TypePrecisionComment
userIdint8Unique record number
userLoginvarchar255Asteriko Login used for web authentication only
userPasswordvarchar32Password for this login
userMailboxPasswordvarchar4Password vor voicemail application
userEmailvarchar255User's E-Mail address
userNamevarchar255User's First name
userGroupIdint8ID of the user group. Only one can be precised at the moment
userLastLoginint11Time of the last authentication
userRegistrationint11Is the user logged in and with whitch sessionID
userLanguagevarchar3Language spoken by the user
userTimeZonevarchar10User's Time Zone
userExtensionvarchar10Unique Extension number of the dialplan
userRedirectGroupIdint8If the user wants to re-route his calls to an other context's extension, the context name must be define here
userRedirectExtvarchar20Allow the user to define or the extension numer corresponding to the context or a full extension name including the protocol type.
userServIdint8Protocol or channel type used to reach the user
userIpvarchar15IP address, domain name, "dynamic" are supported here
userStatuschar1Status of the user. 'y' for Enabled or 'n' for Disabled


Table creation script


Table "ast_groups"


Table's definition

This table allows you to create a link between diffrent users, hosts, services... A group is equivalent to a "context" in Asterisk terminology.

ast_groups
Field NameField TypePrecisionComment
groupIdint8Unique record number
groupNamevarchar255Group name. Equivalent to 'context'
groupDescriptiontextN/AGroup description
groupAccessTimeStartvarchar5Start time the gorup is reachable.
groupAccessTimeStopvarchar5Stop time the gorup is reachable.
groupAccessDaysvarchar60List of week days the gorup is reachable. Each week day is separated by a ";" and are 3 caracters long
groupAccessMonthvarchar20List of months the gorup is reachable.
groupAccessYearvarchar20List of years the gorup is reachable.
groupStatuschar1Status of the group. 'y' for Enabled or 'n' for Disabled


Table creation script


Table "ast_parent_groups"


Table's definition

This table allows you to create a link between one group to one or more groups. Because group are equivalent to a "context" in Asterisk it is important to be able to unclude groups together.

ast_parent_groups
Field NameField TypePrecisionComment
parentGroupId int8Unique record number
parentChildGroupIdint8The group you want to have one or more groups into
parentParentGroupId int8Id of the group you want to include


Table creation script


Table "ast_hosts"


Table's definition

This table is used to define the hosts used by your Asterisk box. The hosts can be or registred or not. If not registred, you will be able to define time, days, months and years when you want this host to be reachable. The protocol used to reach this host is also a compulsory parameter.

ast_hosts
Field NameField TypePrecisionComment
hostsIdint8Unique record number
hostsNamevarchar255Host name
hostPortint4Port number used to connect to the host
hostsLoginvarchar255Login used to connect to the host.
hostsPasswordvarchar32Password linked to the Login
hostsGroupIdint8Context where the host is belonging to
hostsServIdint8Protocol type used to reach the host. The service number is used.
hostsRegistredchar1If the host is a host you want to register to, select true. Can be 'y' or 'n'
hostsAccessTimeStartvarchar5Start time allowed to connect to the host. Ignored for registred hosts.
hostsAccessTimeStopvarchar5Stop time allowed to connect to the host. Ignored for registred hosts.
hostsAccessDaysvarchar60Weekdays list of days allowed to connect to the host. Ignored for registred hosts. Each week day is separated by a ";" and are 3 caracters long
hostsAccessMonthvarchar20Months list of months allowed to connect to the host. Ignored for registred hosts.
hostsAccessYearvarchar20Years list of years allowed to connect to the host. Ignored for registred hosts.
hostStatuschar1Status of the host. 'y' for Enabled or 'n' for Disabled


Table creation script


Table "ast_iax"


Table's defintion

This table is no longer used and has been transfer into a service.

Table "ast_services"


Table's definition

This table defines each available service.

ast_services
Field NameField TypePrecisionComment
servIdint8Unique record number
servNamevarchar40Service name IAX, SIP, H323, ZAP, VoiceMail...
servStatechar1Status of the service. 'y' for Enabled or 'n' for Disabled


Table creation script


Table "ast_services_options"


Table's definition

This table defines each option to a specific service.

ast_services_options
Field NameField TypePrecisionComment
servOptIdint8Unique record number
servIdint8Service concerned by the option
servOptionNamevarchar40Option name.
servOptionValuetextN/AOption value


Table creation script


Table "ast_conf_rooms"


Table definition

This table is used to define the conference rooms as well as passwords and opening hours of each conference room.

ast_conf_rooms
Field NameField TypePrecisionComment
confIdint8Unique record number
confNumbervarchar10Unique conference room number
confPasswordvarchar10Password to acces to the conference room (optionnal)
confAccessTimeStartvarchar5Start time when the conf room is open. hh:mm
confAccessTimeStopvarchar5End time when the conf room is open. hh:mm
confAccessDaysvarchar60Week days when the conf room is open. Each week day is separated by a ";" and are 3 caracters long
confAccessMonthvarchar20Month range when conf room is open
confAccessYearvarchar20Year range when conf room is open
confStatechar1Status of the conf room. 'y' for Enabled or 'n' for Disabled


Table creation script


Table "ast_trunks"


Table's definition

This table defines each trunk or channel between asterisk boxes and what are the numbers used to dial on these trunks.

ast_trunks
Field NameField TypePrecisionComment
trunkIdint8Unique record number
trunkNamevarchar20Trunk name
trunkGroupIdint8Group or context in witch the trunk should belong
trunkServIdint8Type of protocole used for this trunk.
trunkAccessTimeStartvarchar5Starting opening hour of the trunk. hh:mm
trunkAccessTimeStopvarchar5Stoping opening hour of the trunk. hh:mm
trunkAccessDaysvarchar60Week days when the trunk is open. Each week day is separated by a ";" and are 3 caracters long.
trunkStatechar1Status of the trunk. 'y' for Enabled or 'n' for Disabled


Script de création


Contributors to this page: loic91 points  , mose904 points  and hina26 points  .
Page last modified on Sunday 07 November, 2004 [18:58:24 UTC] by loic91 points .

or, for more interaction:
or
Search
in:
Search Wiki PageName
[ Execution time: 0.80 secs ]   [ Memory usage: 14.29MB ]   [ 59 database queries used ]   [ GZIP Enabled ]   [ Server load: 0.03 ]
Last update from CVS: Friday 26 October, 2007 [15:59:54 UTC]