Sunday, December 21, 2014

Asterisk Freeswitch FreePBX FreeTDM Skypopen FusionPbx Mysql Odbc

download Asterisk: Asterisk-13
Libpri: libpri-1.4-current
Dahdi: dahdi-linux-complete-current
Download AsteriskNOW: AsteriskNOW-current-x86_64-DVD

Asternic Call Center Stats Lite:asternic-stats-1.x
Asternic CDR Stats freePBX Module: AsternicCDR1.x

Chan_dongle
chan_dongle-1.1.r14
chan_dongle-asterisk13

download FreePBX
FreePBX13.0.0
FreePBX2.11

Download FreePBX Distro
FreePBX Distro13, 64bit, Asterisk13

freeswitch:freeswitch_install
Automatic Calling subscribers-25,000rubles:
CallCenter | Webinterface | Databaseoutgoingcalls

Installing FreeSWITCH FusionPBX Skypopen FreeTDM DAHDI mode on Centos
yum update
Disable SELinux
/bin/sed-i-es, 'SELINUX=enforcing', 'SELINUX=disabled', /etc/selinux/config
reboot

install dependencies
yum install make ncurses-devel unixODBC-devel openssl-devel gnutls-devel libogg-devel libvorbis-devel curl-devel libtiff-devel libjpeg-devel autoconf automake gcc-c++ git-core libjpeg-devel libtool subversion autoconf
automake libtoolgcc-c++ ncurses-devel makelibX11-devel Xvfbalsa-utilslibXv libXScrnSaver xorg-x11-fonts*alsa-lib libXScrnSaver libtiff-devel libjpeg-devel kernel kernel-devel gitxzxz-devel mesa-dri-drivers
sqlite sqlite-devel pcrepcre-devel speex-devel libedit-devel bison patch
alsa-libfontconfigfreetype glibc libgcc libICElibSMl ibstdc++ libX11 libXau libxcb
libXcursor libXext libXfixes libXi libXinerama libXrandr libXrender libXScrnSaver libXv
php php-pdo php-mysql

set ldns and ldns-devel
yum install ldnsldns-devel-y
yum install http*
yum install mysql*
chkconfig mysqld on
service mysqld start

Ask a MySQL password
/usr/bin/mysqladmin-urootpassword"yourpassword"

Install and configure the ODBC
yum install unixODBC-devel mysql-connector-odbc

We establish a symbolic link from libmyodbc5.soonlibmyodbc.so.[64]-64-batOS.
ln /usr/lib64/libmyodbc5.so /usr/lib64/libmyodbc.so

Run:
odbcinst-j. Displays alist  ofconfiguration files.

#Odbcinst-j
unixODBC2.2.14
DRIVERS............:/etc/odbcinst.ini
SYSTEMDATASOURCES:/etc/odbc.ini
FILEDATASOURCES..:/etc/ODBCDataSources
USERDATASOURCES..:/root/.odbc.ini
SQLULENSize.......:4
SQLLENSize........:4
SQLSETPOSIROWSize.:2

Uncomment the MySQL driver settings /etc/odbcinst.ini
Add  the following in formation to the odbc.ini file located in /etc/odbc.ini

[DEFAULT]
Driver=MySQL

[freeswitch]
Driver=MySQL
SERVER=localhost
PORT=3306
DATABASE=fusionpbx
OPTION=67108864
Socket=/var/lib/mysql/mysql.sock

We establish FreeSwit chcmod_skypopen.

cd /usr/src
git clone https://freeswitch.org/stash/scm/fs/freeswitch.git
cd freeswitch
./bootstrap.sh

git remote set-url origin https://freeswitch.org/stash/scm/fs/freeswitch.git

vim modules.conffile
Uncomment additional modules

mod_rtmp
mod_directory
mod_callcenter
mod_tts_commandline
mod_dingaling
mod_flite
mod_shout
mod_pocketsphinx
mod_cidlookup
mod_skypopen
mod_curl
mod_xml_curl

Install FreeSWITCH

cd /usr/src/freeswitch
./configure
make
make install

8kHz StandardAudio:
make sounds-install
make moh-install

16kHz High Definition Audio:
make hd-moh-install
make hd-sounds-install

32kHz Ultra High Definition Audio:
make uhd-moh-install
make uhd-sounds-install

48kHz CD QualityAudio:
make cd-sounds-install
make cd-moh-install


FreeTDM
https://wiki.freeswitch.org/wiki/FreeTDM
https://wiki.freeswitch.org/wiki/Freetdm.conf_Examples

Establish Skypopen
How to configure skypopen.ko OSSsound driver

Make sure that no audio drivers are not loaded ,otherwise nothing happens.
After entering:
lsmod|grepsnd

If you get a message drivers are loaded, try disabling the sound card in the bios.
Establish the dependence of Skype

yum install libqt xdg libqtxdg-devel qtwebkit qtwebkit-devel

When everything is in order, install audio driver Skypopen.
cd /usr/src/freeswitch/src/mod/endpoints/mod_skypopen/oss
make clean
make
insmod./skypopen.ko
mknod/dev/dspcMarch14

Interactive installer and configurator mod_skypopen.

cd /usr/src/freeswitch/src/mod/endpoints/mod_skypopen/install
./install.pl

Interactive Skype  configurator

Add a startup script inrc.local Skype client

echo "sh/usr/local/freeswitch/skypopen/skype-clients-startup-dir/start_skype_clients.sh">> /etc/rc.d/rc.local

Related Links skypopen:
http://wiki.freeswitch.org/wiki/Mod_skypopen_Skype_Endpoint_and_Trunk

Continue FreeSwitch installation

AddUserFreeswitch:
useraddfreeswitch

Establish rules and owners to files FreeSwitch.
Copy the init script.

cd /usr/local/
chown -Rfreeswitch:freeswitchfreeswitch
chmod -Rg+w freeswitch
cd /usr/local/freeswitch/build
cp freeswitch.init.redhat /etc/init.d/freeswitch
chmod +x /etc/init.d/freeswitch
cp freeswitch.sysconfig /etc/sysconfig/freeswitch

Add installation freeswitch sysconfig

cat >> /etc/sysconfig/freeswitch<<EOT
PID_FILE=/var/run/freeswitch/freeswitch.pid
FS_USER=freeswitch
FS_FILE=/usr/local/freeswitch/bin/freeswitch
FS_HOME=/usr/local/freeswitch
EOT

Change the rights to run an init script and add FreeSwitch to start at boot time.

chmod 765 /etc/init.d/freeswitch
/sbin/chkconfig--add freeswitch
/sbin/chkconfig--level 5 freeswitchon
/sbin/chkconfig--list freeswitch

Remove the default configs FreeSwitch from the default boot.

cd /usr/local/freeswitch/conf/dialplan/default
mv 00_ladspa.xml 00_ladspa.noload
mv 00_pizza_demo.xml 00_pizza_demo.noload
mv 01_Talking_Clock.xml 01_Talking_Clock.noload

Share CLI
cd /usr/local/bin/
ln-s /usr/local/freeswitch /bin/fs_clifs_cli

We establish FusionPBX
cd /var/www/html
mkdirfusionpbx
svn co http://fusionpbx.googlecode.com/svn/trunk/fusionpbxfusionpbx

FusionPBX correct permissions.

cd /var/www/html
chown -R apache:apachefusionpbx

cd /usr/local/freeswitch/conf/
chmod 770 'find.-typed'
chmod 660 'find.-typef'

Add apache user to the group freeswitch.
usermod -a-G freeswitch apache

We star tour services and set them to autostart.
service freeswitch start
service httpd restart
chkconfig freeswitch on
chkconfig httpd on

yum install monit

service monit start
chkconfig monit on

firefox http://youraddress/fusionpbx

softphones:
Zoiper
jitsi
MicroSIP
SjPhone
Phoner
PhonerLite
QuteCom

Saturday, December 13, 2014

Complete working software

Telephony network from scratch

dependency libraries
yum install opencore-amr
From LCR only, this package installs GSM adaptive multirate codecs and the EFR codec. The Full-Rate codec is included in LCR's repository.

wget http://sourceforge.net/projects/opencore-amr/files/opencore-amr/
tar xvzf opencore-amr-x.x.x.tar.gz
cd opencore-amr-x.x.x
./configure
make
make install
ldconfig
cd ..

This package installs the open source SIP stack of Nokia Research Center.

wget http://sourceforge.net/projects/sofia-sip/files/sofia-sip/
tar xvzf sofia-sip-x.xx.xx.tar.gz
cd sofia-sip-x.xx.xx
./configure
make
make install
ldconfig
cd ..


This package installs the open source RTP protocol required for libosmo-abis.

wget http://download.savannah.gnu.org/releases/linphone/ortp/sources/
tar xvzf ortp-x.xx.x.tar.gz
cd ortp-x.xx.x
./configure
make
make install
ldconfig
cd ..
 
yum install sqlite3 libdbi dbd-sqlite3 

This package installs the core utility library for various Osmocom projects.
git clone git://git.osmocom.org/libosmocore.git
cd libosmocore
autoreconf -i
./configure
make
make install
ldconfig
cd ..

This package installs the core utility library for various Osmocom projects.
git clone git://git.osmocom.org/libosmo-abis.git
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure .....

cd libosmo-abis
# change branch:
git checkout -b jolly/multi-trx origin/jolly/multi-trx
autoreconf -i
./configure
(sometimes it is necessary to point to different .../lib/pkgconfig/ path: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure .....)
make
make install
ldconfig
cd ..

This package installs the [wiki:osmo-nitb Osmocom Network In The Box] software
git clone git://git.osmocom.org/openbsc.git
cd openbsc/openbsc/
# change branch:
git checkout -b jolly/testing origin/jolly/testing
autoreconf -i
./configure
(sometimes it is necessary to point to different .../lib/pkgconfig/ path: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure .....)
make
make install
cd ../..


This package installs the open source Base Transceiver Station.
git clone git://git.osmocom.org/osmo-bts.git
cd osmo-bts
#change branch:
git checkout -b jolly/trx origin/jolly/trx
autoreconf -i
./configure --enable-trx
(sometimes it is necessary to point to different .../lib/pkgconfig/ path: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure .....)
make
make install
cd ..

This package installs the open source PBX software to bridge ISDN (DSS1) / SIP / GSM (MNCC protocol)
git clone git://git.misdn.eu/lcr.git/
cd lcr
autoreconf -i
./configure --with-sip --with-gsm-bs --with-gsm-ms
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure .....
make
make install
ldconfig
cd ..


Configuration examples

OsmoBTS
mkdir ~/.osmocom
vim ~/.osmocom/osmo-bts.cfg

bts 0
 band DCS1800
 ipa unit-id 1801 0
 oml remote-ip 127.0.0.1
 rtp bind-ip 127.0.0.1
 rtp jitter-buffer 0
 paging lifetime 0
 gsmtap-sapi bcch
 gsmtap-sapi ccch
 gsmtap-sapi rach
 gsmtap-sapi agch
 gsmtap-sapi pch
 gsmtap-sapi sdcch
 gsmtap-sapi pacch
 gsmtap-sapi pdtch
 gsmtap-sapi sacch
 fn-advance 20
 ms-power-loop -10
 timing-advance-loop
 trx 0
  rxgain 0
  power 0

OpenBSC
mkdir ~/.osmocom
vim ~/.osmocom/open-bsc.cfg

Change 'arfcn' to a frequency you have license for

e1_input
 e1_line 0 driver ipa
 e1_line 0 port 0
network
 network country code 262
 mobile network code 42
 short name OpenBSC
 long name OpenBSC
 auth policy accept-all
 location updating reject cause 13
 encryption a5 0
 neci 1
 paging any use tch 0
 rrlp mode ms-based
 mm info 1
 handover 0
 handover window rxlev averaging 10
 handover window rxqual averaging 1
 handover window rxlev neighbor averaging 10
 handover power budget interval 6
 handover power budget hysteresis 3
 handover maximum distance 9999
 timer t3101 10
 timer t3103 0
 timer t3105 0
 timer t3107 0
 timer t3109 0
 timer t3111 0
 timer t3113 60
 timer t3115 0
 timer t3117 0
 timer t3119 0
 timer t3122 10
 timer t3141 0
 dtx-used 0
 subscriber-keep-in-ram 0
 bts 0
  type sysmobts
  band DCS1800
  cell_identity 0
  location_area_code 1
  training_sequence_code 7
  base_station_id_code 63
  ms max power 0
  cell reselection hysteresis 4
  rxlev access min 0
  periodic location update 30
  channel allocator descending
  rach tx integer 9
  rach max transmission 7
  channel-descrption attach 1
  channel-descrption bs-pa-mfrms 5
  channel-descrption bs-ag-blks-res 1
  ip.access unit_id 1801 0
  oml ip.access stream_id 255 line 0
  neighbor-list mode automatic
  trx 0
   rf_locked 0
   arfcn 869
   nominal power 0
   max_power_red 0
   rsl e1 tei 0
    timeslot 0
     phys_chan_config CCCH+SDCCH4
     hopping enabled 0
    timeslot 1
     phys_chan_config TCH/F
     hopping enabled 0
    timeslot 2
     phys_chan_config TCH/F
     hopping enabled 0
    timeslot 3
     phys_chan_config TCH/F
     hopping enabled 0
    timeslot 4
     phys_chan_config TCH/F
     hopping enabled 0
    timeslot 5
     phys_chan_config TCH/F
     hopping enabled 0
    timeslot 6
     phys_chan_config TCH/F
     hopping enabled 0
    timeslot 7
     phys_chan_config TCH/F
     hopping enabled 0


Linux-Call-Router (LCR) (optional)
vim /usr/local/etc/lcr/options.conf
Add a line to show logging to the console:
debug 0x100000

The simplest configuration uses only the GSM interface. It allows LCR to forward calls from GSM to GSM or from GSM to a call test feature.

vim /usr/local/etc/lcr/interface.conf

You can remove or comment everything and just add this interface:
[gsm]
gsm-bs
tones yes
earlyb no
extern


routing.conf
vim /usr/local/etc/lcr/routing.conf

You can remove or comment everything and just add these rulesets:

[main]
interface=gsm                           : goto ruleset=gsm
                                        : disconnect cause=31

[gsm]
dialing=99                              : test
                                        : extern interfaces=gsm


Look at the gsm rule set. All calls that dial '99' prefix, will be test calls. All other calls will be forwarded back to 'gsm' interface.

Running 
Open a shell and start OpenBSC:
osmo-nitb -c ~/.osmocom/open-bsc.cfg -l ~/.osmocom/hlr.sqlite3 -P -C --debug=DRLL:DCC:DMM:DRR:DRSL:DNM

OpenBSC runs as a stand-alone network with given config file and data base. In order to use LCR, add '-m' option. In this case the LCR replaces the built-in call control.
osmo-nitb -c ~/.osmocom/open-bsc.cfg -l ~/.osmocom/hlr.sqlite3 -P -m -C --debug=DRLL:DCC:DMM:DRR:DRSL:DNM

Very important is the option '-C'. On certain machines, osmo-nitb will halt from time to time while writing counters to database. This Without this option, audio might interrupt several seconds from time to time.
The debugging is usefull for early tests, because you will quickly see what happens if a mobile requests something.

<0005> bsc_init.c:422 
WARNING: You are running an 'accept-all' network on a BTS that is not barred.
This configuration is likely to interfere with production GSM networks and
should only be used in a RF shielded environment such as a faraday cage!

<0019> input/ipaccess.c:925 enabling ipaccess BSC mode
DB: Database initialized.
DB: Database prepared.
<001d> sms_queue.c:220 Attempting to send 20 SMS


Open a shell and start OsmoBTS:
osmobts-trx -c ~/.osmocom/osmo-bts.cfg

Refer to the [wiki:OsmoTRX] page on how to run OsmoTRX.
 
The installation/setup/calibration of UmTRX is beyond the scope of this document. Please refer to:
https://github.com/fairwaves
http://files.ettus.com/uhd_docs/manual/html/build.html
http://wush.net/trac/rangepublic/wiki/BuildInstallRun

calypso-BTS
Building Osmocom-BB with arm-elf toolchain is also beyond the scope of this document. If you managed to compile and run Osmocom-BB you should be able to run the transceiver too.
git clone git://git.osmocom.org/libosmo-dsp.git
git clone git://git.osmocom.org/osmocom-bb.git
In order to compile Osmocom-BB with transceiver support, do the following:
cd libosmo-dsp
autoreconf -i
./configure
(sometimes it is necessary to point to different .../lib/pkgconfig/ path: PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ ./configure .....)
make
make install
cd ..

cd osmocom-bb
# change branch:
git checkout -b jolly/testing origin/jolly/testing
cd src
make
# after it compiles, just enable transceiver support
cd host/layer23
./configure --enable-transceiver
make

'''NOTE: "ms-power-loop" at osmo-bts.cfg should be set to -65, in order to prevent saturating the input. Also if the phone is only one or few meters away, "ms max power" should be set to 0. In case of long distance test it can be set to 30 (DCS) or 33 (GSM 900).'''

Now you should start with a single phone for one timeslot only. If it works, you can try two phones to serve two timeslots. Since you have only one slot, you will only be able to transmit broadcast, do location updating and send/receive SMS. Here is the "osmo-bts.cfg" for a single timeslot:
bts 0
 band DCS1800
 ipa unit-id 1801 0
 oml remote-ip 127.0.0.1
 rtp jitter-buffer 0
 paging queue-size 200
 paging lifetime 0
 fn-advance 30
 ms-power-loop -60
 timing-advance-loop
 settsc
 setbsic
 trx 0
  rxgain 0
  power 0
  slotmask 1 0 0 0 0 0 0 0

Run osmocon and transceiver application in separate shells:
# Please refer to Osmocom-BB wiki for compiling and running own firmware on compal phones...
osmocon -p /dev/ttyUSB0 -m c123xor -c path_to/trx.highram.bin -r 99

transceiver -e 5 -r 99

When using two phones, two timeslots can be served. I suggest to configure second timeslot (TS 1) as TCH/H at openbsc.cnf. This way it is possible to allow two traffic channels on a single timeslot. If you do a call from one phone to another, you will need one channel for each phone. In order to use two phones, you need to change the alot map of osmo-bts.cnf:
  slotmask 1 1 0 0 0 0 0 0

Run two osmocon and transceiver application in separate shells:
osmocon -p /dev/ttyUSB0 -m c123xor -c path_to/trx.highram.bin -r 99

# This osmocon connects to the serial interface of the second phone.
# Note: "/tmp/osmocom_l2.2" is the second socket to which the transceiver will connect.
osmocon -p /dev/ttyUSB1 -s /tmp/osmocom_l2.2 -m c123xor -c path_to/trx.highram.bin -r 99

transceiver -e 5 -r 99 -2

Run Linux-Call-Router (LCR) (optional) with debugging output
lcr start


Test
Location Updating 
Switch on the phone.
If you have a SIM card for your network 262 42, you can use it and do automatic network search. If not, do a manual network and select this network. You should see debugging output on OpenBSC like this:
 <0002> gsm_04_08.c:424 -> LOCATION UPDATE ACCEPT

Call the music (LCR required)
Now enter phone number 995 to select the test function 5 of LCR. This test function just plays the hold music.
Echo and BFI test (LCR required) 

Enter phone number 993 to select the test function 3 of LCR. This test function echoes back everything that is received. Note that it will re-transcode the speech data, so the audio from your voice is compressed and decompressed twice until you can hear a fraction of a second later.

You may experience short beeps. These beeps represent all bad frames that could not be decoded or got lost over the air. (Without this test, the missing frames will be extrapolated from previous frame, so some loss rate will not be recognized by the remote end.)

Original post is here
http://openbsc.osmocom.org/trac/wiki/network_from_scratch

Radius Active Directory Cisco

Debian/Ubuntu
tar zxf freeradius-server-2.X.Y.tar.gz
cd freeradius-server-2.X.Y
fakeroot dpkg-buildpackage -b -uc
dpkg -i ../*freeradius*_2.X.Y-*_*.deb
add-apt-repository ppa:freeradius/stable-3.0
or
deb http://ppa.launchpad.net/freeradius/stable-3.0/ubuntu UBUNTU_VERSION_HERE main
deb-src http://ppa.launchpad.net/freeradius/stable-3.0/ubuntu UBUNTU_VERSION_HERE main

apt-get install dpkg-dev
apt-get build-dep freeradius


Dependencies
For OpenCSW install GCC
pkg-util -i -y gcc4-core
FreeRadius on Solaris
./configure
make
make install

export PATH='/usr/sbin:/usr/bin:/opt/csw/bin:/opt/csw/gcc3/bin:/usr/ccs/bin:/opt/SUNWspro/bin'
export CFLAGS='-I/usr/local/openldap/include/ -I/usr/local/mysql/include/mysql/ -I/opt/csw/include/'
export LDFLAGS='-L/usr/local/openldap/lib/ -R/usr/local/openldap/lib -L/usr/local/mysql/lib -R/usr/local/mysql/lib -L/opt/csw/lib -R/opt/csw/lib'
export LD_OPTIONS='-L/usr/local/openldap/lib/ -R/usr/local/openldap/lib -L/usr/local/mysql/lib -R/usr/local/mysql/lib -L/opt/csw/lib -R/opt/csw/lib'
./configure --prefix=/usr/local/freeradius-1.1.2-mysql-ldap --with-ldap --with-mysql-dir=/usr/local/mysql-5.0.21
gmake
gmake install

vim /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/install-tools/mkheaders.conf
SHELL=/bin/sh
SYSTEM_HEADER_DIR="/usr/include"
OTHER_FIXINCLUDES_DIRS=""
FIXPROTO_DEFINES=""
STMP_FIXPROTO="stmp-fixproto"
STMP_FIXINC="stmp-fixinc"

Rebuild the headers.
./mkheaders


On mac
curl -LO http://www.samba.org/ftp/talloc/talloc-2.1.0.tar.gz
 tar zxvf talloc-2.1.0.tar.gz
 cd talloc-2.1.0
./configure --without-gettext
 make
 make install

 cd ../
 curl -LO ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-3.0.0.tar.gz
 tar zxvf freeradius-server-3.0.0.tar.gz
 cd freeradius-server-3.0.0
./configure --enable-developer
 make
 make install



Centos
yum install freeradius
yum upgrade freeradius
yum install freeradius-mysql

yum --enablerepo=updates-testing update freeradius

yum info freeradius\*
rpm -qa freeradius\*
rpm -qf /usr/lib/freeradius/rlm_sql_mysql.so
yum whatprovides /usr/lib/freeradius/rlm_sql_mysql\*.so 
service radiusd start
chkconfig radiusd on
chkconfig --list radiusd
chkconfig radiusd off
rpm -ql freeradius-mysql
rpm -qlp /usr/src/redhat/RPMS/i386/freeradius-mysql-2.1.1-7.fc10.i386.rpm
rpm -qf /usr/lib/freeradius/rlm_sql_mysql-2.1.1.so
yum install rpm-build
yum install yum-utils
yum install  freeradius freeradius-libs freeradius-utils freeradius-ldap freeradius-python freeradius-mysql
for manual installation of dependencies packages
rpm -Uhv /usr/src/redhat/RPMS/pkgName.x86_64.rpm

For CentOS CentOS-6 run the following as root:

cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/home:freeradius:3.0.x:centos/CentOS_CentOS-6/home:freeradius:3.0.x:centos.repo
yum install freeradius


vim smb.conf
[global]

# workgroup = NT-Domain-Name or Workgroup-Name
  workgroup = XYZDOM  //the name of your domain

# Security mode. Most people will want user level
# security. See security_level.txt for details.
  security = ads


======== Share Definitions ========

 ...
 winbind use default domain = no
 password server = XYZSRV.XYZ-COMPANY.COM //your AD-server
 realm = XYZ-COMPANY.COM      //your realm

[homes]
comment = Home Directories
browseable = no
writable = yes

vim etc/krb5.conf.
[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = EXAMPLE.COM
 dns_lookup_realm = false
 dns_lookup_kdc = false

[realms]
 EXAMPLE.COM = {
  kdc = kerberos.example.com:88
  admin_server = kerberos.example.com:749
  default_domain = example.com
 }

 XYZ-COMPANY.COM = {
  kdc = XYZSRV.XYZ-COMPANY.COM
 }

[domain_realm]
 .example.com = EXAMPLE.COM
 example.com = EXAMPLE.COM

[kdc]
  profile = /var/kerberos/krb5kdc/kdc.conf

[appdefaults]
 pam = {
  debug = false
  ticket_lifetime = 36000
  renew_lifetime = 36000
  forwardable = true
  krb4_convert = false
 }

vim /etc/nsswitch.conf
#and add winbind at the end of each line shown below
passwd:     files winbind
shadow:     files winbind
group:      files winbind

protocols:  files winbind
services:   files winbind
netgroup:   files winbind
automount:  files winbind


reboot

ps –ef | grep nmbd
ps –ef | grep smbd
net join –U Administrator
Administrator is the name of the domain controller admin. Enter your password when prompted. If everything works fine, the Linux server has been registered to the Windows domain.

Verify now if the winbindd daemon is running
ps –ef | grep winbindd

Try next if you can authenticate a user from the domain
wbinfo –a user%password

The error is absolutely normal in this case because there are no cleartext user credentials on the domain Controller (Active Directory) for this user

challenge/response password authentication succeeded

Type the following line
ntlm_auth –-request-nt-key –-domain=<your domain> –-username=<your username>

For example
ntlm_auth –-request-nt-key –-domain=XYZDOM –-username=example_user

You will be prompted for your password.
The command line returns
NT_STATUS_OK : Success (0x0)
If the username and password are the same as those stored in Active Directory.

The radiusd.conf file sets the uid and gid your radiusd process will run as (by the user and group directives, respectively). The ntlm_auth process will have the same identity. If your filesystem containing the winbindd_privileged directory supports POSIX ACLs, you can safely grant ntlm_auth the necessary permissions, in case your disribution's default setting were insufficient. If radiusd runs as the user radiusd for example, then you should use setfacl the following way

setfacl -m u:radiusd:rx winbindd_privileged

man setfacl
for more information on POSIX ACLs!

In order to get FreeRADIUS working, the following files must be configured:
    clients.conf
    mods-available/mschap
    mods-available/eap
    users

vim clients.conf
client 192.168.2.44 {
        secret                = 2!34r&dp0t
        shortname             = 192.168.2.44
        nastype               = cisco
}

#Shared secret for them all

client 192.168.2.0/24 {
        secret          = 2!34r&dp0t
        shortname       = network1
}

mods-available/mschap
with_ntdomain_hack = yes

ntlm_auth = "/path/to/ntlm_auth --request-nt-key --username=%{%{Stripped-User-Name}:-%{%{User-Name}:-None}} --challenge=%{%{mschap:Challenge}:-00} --nt-response=%{%{mschap:NT-Response}:-00}"

--domain=%{mschap:NT-Domain}

mods-available/eap

default_eap_type = peap.

tls-config tls-common {

random_file = /dev/urandom.


vim raddb/users 

username1     Cleartext-Password := "user-password1", MS-CHAP-Use-NTLM-Auth := 0
username2     Cleartext-Password := "user-password2", MS-CHAP-Use-NTLM-Auth := 0
username3     Cleartext-Password := "user-password3", MS-CHAP-Use-NTLM-Auth := 0

authorize {
    ...
    #  Read the 'users' file
    files   # <--- This one!
    ...
}


Activate AAA (Authentication, Authorization, Accounting)
enable aaa new-model

Create a list of authentication methods by using Radius group as default.
aaa authentication dot1x default group radius

Activate authorization for using dynamic VLAN assignment by Radius.
aaa authorization network default group radius

Configure parameters of Radius server. In this case we use IP 192.168.2.16 and the default ports 1812 and 1813
radius-server host 192.168.2.16 auth-port 1812 acct-port 1813 timeout 3

Configure the maximum number of retransmissions to the server for the requests
radius server retransmit 3

Configure the shared secret between switch and Radius server.
radius server key <mysharedsecret>

Please use the secret that you have specified in the clients.conf file.
Next we must configure each interface (port) to operate in 802.1X mode.
Repeat this procedure for each port that should do access control

configure terminal
(config)#interface FastEthernet1/0/12
(config-if)# switchport mode access
(config-if)# dot1x port-control auto
(config-if)# end

The command show dot1x< allows to check 802.1X settings.
Do not forget to save the configuration of your switch.
copy running-config startup-config

vim /usr/local/openssl/ssl/openssl.cnf
# req_extensions = v3_req

# The extensions to add to a certificate request

[ req_distinguished_name ]

countryName = Country Name (2 letter code)
countryName_default = LU
countryName_min = 2
countryName_max = 2

stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Luxembourg

localityName = Locality Name (eg, city)
localityName_default = Luxembourg-city

0.organizationName = Organization Name (eg, company)
0.organizationName_default = XYZ

organizationalUnitName = Organizational Unit Name
organizationalUnitName_default = IT

commonName = Common Name (eg, YOUR name)
commonName_max = 64
commonName_default = administrator

emailAddress = Email Address
emailAddress_max = 40
emailAddress_default = operations@xyz.com

# SET-ex3 = SET extension number 3

[ req_attributes ]

challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
challengePassword_default = whatever

unstructuredName = An optional company name


echo "newreq.pem" | /usr/local/openssl/ssl/misc/CA.pl –newca
find / -name CA.all

Move all the files to /etc/raddb/certs/

Needed equipments

Chinese FXO/FXS cards. 4 ports card only cost around $55 USD.

http://openbsc.osmocom.org/trac/wiki/network_from_scratch

Rafael Micro RTL-SDR (R820T)    24-1766MHz 3.2MS/s 8bit    No    ~20

Elonics E4000    52 – 2200 MHz with a gap from 1100 MHz to 1250 MHz (varies)
has closed and is expensive

HackRF vs. BladeRF low cost tech similar to USRP
in use with gnu radio for signal control in time

http://www.rtl-sdr.com/tag/bladerf/

https://github.com/RangeNetworks/dev/wiki#running

https://github.com/Nuand/bladeRF/wiki/Getting-Started%3A-Linux#Redhatbased_distros_eg_Fedora_CentOS

http://www.yatebts.com/play_video.php

http://galaxyehacker.blogspot.it/2014/01/super-sim-sim-max.html
pySIM python application for USB SIM card reader / writer

priceangels.com
pandawill.com
dealextreme.com

Big Blue Button

grep "multiverse" /etc/apt/sources.list

apt-get update
apt-get dist-upgrade

Add the BigBlueButton key

wget http://ubuntu.bigbluebutton.org/bigbluebutton.asc -O- | sudo apt-key add -

Add the BigBlueButton repository URL and ensure the multiverse is enabled
echo "deb http://ubuntu.bigbluebutton.org/trusty-090/ bigbluebutton-trusty main" | sudo tee /etc/apt/sources.list.d/bigbluebutton.list

apt-get update
apt-get upgrade
vim ffmpeg.sh
copy and paste in the following script:

sudo apt-get install build-essential git-core checkinstall yasm texi2html libvorbis-dev libx11-dev libvpx-dev libxfixes-dev zlib1g-dev pkg-config netcat

FFMPEG_VERSION=2.3.3

cd /usr/local/src
if [ ! -d "/usr/local/src/ffmpeg-${FFMPEG_VERSION}" ]; then
  sudo wget "http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.bz2"
  sudo tar -xjf "ffmpeg-${FFMPEG_VERSION}.tar.bz2"
fi

cd "ffmpeg-${FFMPEG_VERSION}"
sudo ./configure --enable-version3 --enable-postproc --enable-libvorbis --enable-libvpx
sudo make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:${FFMPEG_VERSION}" --backup=no --deldoc=yes --default

Make the script runnable and run it

chmod +x ffmpeg.sh
./ffmpeg.sh


apt-get update
apt-get install bigbluebutton

ignore error like :
...... Error: FreeSWITCH didn't start

else if error = Setting up bbb-playback-presentation (0.9.0-1ubuntu5) ...
chown: invalid user: ‘tomcat7:tomcat7’
then
apt-get install bigbluebutton

To interactively test your BigBlueButton server, you can install a set of API demos.
apt-get install bbb-demo

You'll need the bbb-demo package installed if you want to join the Demo Meeting from your BigBlueButton server's welcome page. This is the same welcome page you see at dev081 demo server.

Later on, if you wish to remove the API demos, you can enter the command
apt-get purge bbb-demo

Enable webRTC audio
To enable webRTC audio, do the following
bbb-conf --enablewebrtc

Do a Clean Restart
To ensure BigBlueButton has started cleanly, enter the following commands:
bbb-conf --clean
bbb-conf --check

To upgrade earlier versions of BigBlueButton 0.9.0-beta, do the following:
apt-get update
apt-get dist-upgrade

bbb-conf --enablewebrtc
bbb-conf --clean
bbb-conf --check

Respond with 'Y', if you get prompted to update any configuration file during the upgrade
Troubleshooting

If you encounter an error at one of the installation/upgrade steps,
Run
bbb-conf --check

We've built in a BigBlueButton configuration utility, called bbb-conf, to help you configure your BigBlueButton server and trouble shoot your setup if something doesn't work right.

If you think something isn't working correctly, the first step is enter the following command.
bbb-conf --check

This will check your setup to ensure the correct processes are running, the BigBlueButton components have correctly started, and look for common configuration problems that might prevent BigBlueButton from working properly.

 try replacing your /etc/apt/sources.list with the following:
deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse

then do
apt-get update

To change all of BigBlueButton's configuration files to use a different IP address or hostname, enter
bbb-conf --setip <ip_address_or_hostname>

Setting audio if not working
vim  /opt/freeswitch/conf/vars.xml

Remove this line
<X-PRE-PROCESS cmd="set" data="local_ip_v4=xxx.yyy.zzz.qqq"/>

Change
<X-PRE-PROCESS cmd="set" data="bind_server_ip=auto"/>

To
<X-PRE-PROCESS cmd="set" data="bind_server_ip=EXTERNAL_IP_ADDRESS"/>

Change
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=stun:stun.freeswitch.org"/>

To
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=EXTERNAL_IP_ADDRESS"/>

Change
<X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.freeswitch.org"/>

To
<X-PRE-PROCESS cmd="set" data="external_sip_ip=EXTERNAL_IP_ADDRESS"/>

vim /opt/freeswitch/conf/sip_profiles/external.xml
Change
    <param name="rtp-ip" value="$${local_ip_v4}"/>
    <param name="sip-ip" value="$${local_ip_v4}"/>
    <param name="ext-rtp-ip" value="$${local_ip_v4}"/>
    <param name="ext-sip-ip" value="$${local_ip_v4}"/>

to

    <param name="rtp-ip" value="$${local_ip_v4}"/>
    <param name="sip-ip" value="$${local_ip_v4}"/>
    <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
    <param name="ext-sip-ip" value="$${external_sip_ip}"/>

vim /usr/share/red5/webapps/sip/WEB-INF/bigbluebutton-sip.properties

bbb.sip.app.ip=<internal ip>
bbb.sip.app.port=5070

freeswitch.ip=<internal ip>
freeswitch.port=5060

vim /etc/bigbluebutton/nginx/sip.nginx to

location /ws {
        proxy_pass http://EXTERNAL_IP_ADDRESS:5066;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_read_timeout 6h;
        proxy_send_timeout 6h;
        client_body_timeout 6h;
        send_timeout 6h;
}

changing EXTERNAL_IP_ADDRESS to your server's elastic IP address.

Open the firewall (if you have on installed) and Security Groups (if your using EC2) the following ports:
TCP - 5066
UDP - 16384 to 32768


see also OpenMeetings
and BulkSMS

FreePBX and Asterisk configuration

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
reboot

yum install wget gcc gcc-c++ ncurses-devel libxml2-devel sqlite-devel libuuid-devel openssl-devel screen lsof mlocate gnutls-devel kernel-devel subversion doxygen texinfo curl-devel net-snmp-devel neon-devel uuid-devel sqlite-devel sqlite git speex-devel gsm-devel

apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mysql-server mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git subversion unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev libiksemel-dev libiksemel-utils libiksemel3


pear uninstall db
pear install db-1.7.14

yum install libsrtp-devel

If libsrtp is not available in the repo install it from source.
cd /usr/local/src/
wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
tar zxvf srtp-1.4.2.tgz
cd /usr/local/src/srtp
./configure CFLAGS=-fPIC
or
./configure --enable-pic --libdir=/usr/lib64
make && make install
or

git clone https://github.com/cisco/libsrtp.git
cd libsrtp/
autoconf
./configure CFLAGS=-fPIC --prefix=/usr
make
make runtest
make install

 wget http://www.digip.org/jansson/releases/jansson-2.5.tar.gz
tar zxvf jansson-2.5.tar.gz
cd jansson-2.5
./configure --libdir=/usr/lib64
make & make install

Installing PJSIP

git clone https://github.com/asterisk/pjproject pjproject
cd pjproject
./configure --libdir=/usr/lib64 --prefix=/usr --enable-shared
             --disable-sound --disable-resample --disable-video --disable-opencore-amr
             --with-external-speex --with-external-srtp --with-external-gsm
make dep && make && make install
cd ..


cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz

wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
cd /usr/src
tar xvfz dahdi-linux-complete-current.tar.gz
tar xvfz libpri-1.4-current.tar.gz
rm -f dahdi-linux-complete-current.tar.gz libpri-1.4-current.tar.gz
cd dahdi-linux-complete-*
make all
make install
make config
cd /usr/src/libpri-1.4.*
make
make install

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
make menuselect

After selecting 'Save & Exit' you can then continue
make
make install
make config
ldconfig
Install Asterisk-Extra-Sounds

Installs the (8khz) 'wav' soundfiles and G722 (High Definition 'Wideband') audio.
mkdir -p /var/lib/asterisk/sounds
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz


git clone https://github.com/akheron/jansson.git
cd /usr/src/jansson
autoreconf -i
./configure
make
make install

wget http://www.pjsip.org/release/2.2.1/pjproject-2.2.1.tar.bz2
cd /usr/src
tar -xjvf pjproject-2.2.1.tar.bz2
cd pjproject-2.2.1
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound\
  --disable-resample --disable-video --disable-opencore-amr
make dep
make
make install


Install Asterisk
cd /usr/local/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-13.0.0.tar.gz
tar zxvf asterisk*
cd /usr/local/src/asterisk*.
./configure --libdir=/usr/lib64
make menuselect

enable res_srtp

make && make install
make samples
make config

Running Asterisk

asterisk
asterisk -vvvr
And you get

localhost*CLI> core show version

DTLS
mkdir /etc/asterisk/keys
cd /usr/local/src/asterisk*/contrib/scripts
Create the DTLS certificates (replace pbx.mycompany.com with your ip address

or dns name, replace My Super Company with your company name)
./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys.



Install and Configure FreePBX
export VER_FREEPBX=12.0
cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}
Now create the Asterisk user and set ownership permissions.
useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html
A few small modifications to Apache.
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
service apache2 restart
Prepare MySQL

You now need to generate a secure password for FreePBX to use to talk to MySQL.
export ASTERISK_DB_PW=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 - | cut -c2-18`

That will generate a quasi-random 16 character long password, which should be secure enough for most things.  If you had set the MySQL 'root' password to be something when you were installing the machine, you will need to add a -pyourpassword flag to the following lines
Configure Asterisk database in MYSQL.
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
Set permissions on MYSQL database.
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "flush privileges;"
Restart Asterisk and install FreePBX.
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
amportal a ma installall
amportal a reload
amportal chown
Finally, one last mod and start FreePBX.
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal start
Start FreePBX

Now FreePBX is installed,
firefox http://Address.Of.FreePBX.Server/admin


Astrisk command line and configuration

rasterisk

reload

sip reload

ps aux | grep asterisk

For sip.conf & extension.conf
context=inside  -> for internal calls not recommended for a large number of users

odbc show

isql -v MySQL-asterisk

module show like odbc

cat /etc/asterisk/cdr.conf | grep -v '^;' | grep -v '^$'

cat /etc/asterisk/res_odbc.conf | grep -v '^;' | grep -v '^$'

vim /etc/asterisk/cdr.conf
/etc/init.d/asterisk restart

[span3pri]
exten => _50054XX,1,NoOp()
   same => n,Set(CDR(accountcode)=pricall)
   same => n,GotoIf($[${ODBC_ANIBLOCK(${CALLERID(number)})}]?busy)
   same => n(dial),Dial(DAHDI/G1/${EXTEN})
   same => n(busy),Busy(10)
   same => n,Hangup

[ANIBLOCK]
dsn=telesys
readsql=SELECT IF(COUNT(1)>0, 1, 0) FROM Aniblock WHERE NUMBER='${ARG1}'


vim sip.conf 

; sip.conf
; HOT DESK USERS
[0000FFFF0001]
type=friend
host=dynamic
secret=my_special_secret
context=hotdesk
qualify=yes

[0000FFFF0002]
type=friend
host=dynamic
secret=my_special_secret
context=hotdesk
qualify=yes

; END HOT DESK USERS


su - postgres
$ psql -U asterisk -h localhost asterisk
Password:

Then create the table with the following bit of SQL:

CREATE TABLE ast_hotdesk
(
  id serial NOT NULL,
  extension int8,
  first_name text,
  last_name text,
  cid_name text,
  cid_number varchar(10),
  pin int4,
  context text,
  status bool DEFAULT false,
  "location" text,
  CONSTRAINT ast_hotdesk_id_pk PRIMARY KEY (id)
)
WITHOUT OIDS;

For MySQL:

$ mysql -u asterisk -p asterisk
Enter password:

Then create the table with the following bit of SQL:

CREATE TABLE ast_hotdesk
(
  id serial NOT NULL,
  extension int8,
  first_name text,
  last_name text,
  cid_name text,
  cid_number varchar(10),
  pin int4,
  context text,
  status bool DEFAULT false,
  location text,
  CONSTRAINT ast_hotdesk_id_pk PRIMARY KEY (id)
);


A simple example follows. Suppose we have the following func_odbc.conf:

[ALL_AVAIL_EXTENS]
prefix=GET
dsn=asterisk-connector
mode=multirow
readsql=SELECT extension FROM ast_hotdesk WHERE status = '${ARG1}'

and a dialplan in extensions.conf that looks something like this:

[multirow_example]
exten => start,1,Verbose(1,Looping example)
   same => n,Set(ODBC_ID=${GET_ALL_AVAIL_EXTENS(1)})
   same => n,GotoIf($[${ODBCROWS} < 1]?no_rows,1)
   same => n,Set(COUNTER=1)
   same => n,While($[${COUNTER} <= ${ODBCROWS}])
   same => n,Set(AVAIL_EXTEN_${COUNTER}=${ODBC_FETCH(${ODBC_ID})})
   same => n,Set(COUNTER=$[${COUNTER + 1])
   same => n,EndWhile()
   same => n,ODBCFinish()

exten => no_rows,1,Verbose(1,No rows returned)
   same => n,Playback(silence/1&invalid)
   same => n,Hangup()
  
  

Here’s another extensions.conf example:

[multirow_example_2]
exten => start,1,Verbose(1,Looping example with break)
   same => n,Set(ODBC_ID=${GET_ALL_AVAIL_EXTENS(1)})
   same => n(loop_start),NoOp()
   same => n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})})
   same => n,GotoIf($["${ODBC_FETCH_RESULT}" = "FAILURE"]?cleanup,1)
   same => n,GotoIf($["${ROW_RESULT}" = "1104"]?good_exten,1)
   same => n,Goto(loop_start)

exten => cleanup,1,Verbose(1,Cleaning up after all iterations)
   same => n,Verbose(1,We did not find the extension we wanted)
   same => n,ODBCFinish(${ODBC_ID})
   same => n,Hangup()

exten => good_exten,1,Verbose(1,Extension we want is available)
   same => n,ODBCFinish(${ODBC_ID})
   same => n,Verbose(1,Perform some action we wanted)
   same => n,Hangup()
  
  
[PHONE_STATUS]
prefix=HOTDESK
dsn=asterisk
readsql=SELECT extension FROM ast_hotdesk WHERE status = '1'
readsql+= AND location = '${ARG1}'

If we try to dial a number that is not handled by our context (or one of the transitive contexts—i.e., international contains long distance, which also contains local), the built-in extension i is executed, which plays back a message stating that the action cannot be performed and hangs up the call:

[hotdesk_outbound]
exten => _X.,1,NoOp()
   same => n,Set(LOCATION=${CUT(CHANNEL,/,2)})
   same => n,Set(LOCATION=${CUT(LOCATION,-,1)})
   same => n,Set(WHO=${HOTDESK_PHONE_STATUS(${LOCATION})})
   same => n,GotoIf($[${ISNULL(${WHO})}]?no_outgoing,1)
   same => n,Set(${WHO}_CID_NAME=${HOTDESK_INFO(cid_name,${WHO})})
   same => n,Set(${WHO}_CID_NUMBER=${HOTDESK_INFO(cid_number,${WHO})})
   same => n,Set(${WHO}_CONTEXT=${HOTDESK_INFO(context,${WHO})})
   same => n,Goto(${${WHO}_CONTEXT},${EXTEN},1)

[international]
exten => _011.,1,NoOp()
   same => n,Set(E=${EXTEN})
   same => n,Goto(outgoing,call,1)

exten => i,1,NoOp()
   same => n,Playback(silence/2&sorry-cant-let-you-do-that2)
   same => n,Hangup()

include => longdistance

[longdistance]
exten => _1NXXNXXXXXX,1,NoOp()
   same => n,Set(E=${EXTEN})
   same => n,Goto(outgoing,call,1)

exten => _NXXNXXXXXX,1,Goto(1${EXTEN},1)

exten => i,1,NoOp()
   same => n,Playback(silence/2&sorry-cant-let-you-do-that2)
   same => n,Hangup()

include => local

[local]
exten => _416NXXXXXX,1,NoOp()
   same => n,Set(E=${EXTEN})
   same => n,Goto(outgoing,call,1)

exten => i,1,NoOp()
   same => n,Playback(silence/2&sorry-cant-let-you-do-that2)
   same => n,Hangup()

If the call is allowed to be executed, it is sent to the [outgoing] context for processing and the caller ID name and number are set with the CALLERID() function. The call is then placed via the SIP channel using the service_provider we created in the sip.conf file:

[outgoing]
exten => call,1,NoOp()
   same => n,Set(CALLERID(name)=${${WHO}_CID_NAME})
   same => n,Set(CALLERID(number)=${${WHO}_CID_NUMBER})
   same => n,Dial(SIP/service_provider/${E})
   same => n,Playback(silence/2&pls-try-call-later)
   same => n,Hangup()

Our service_provider might look something like this in sip.conf:

[service_provider]
type=friend
host=switch1.service_provider.net
defaultuser=my_username
fromuser=my_username
secret=welcome
context=incoming
canreinvite=no
disallow=all
allow=ulaw

Now that we’ve implemented a fairly complex feature in the dialplan with the help of func_odbc to retrieve and store data in a remote relational database, hopefully you’re starting to get why we think this is so cool. With a handful of self-defined dialplan functions in the func_odbc.conf file and a couple of tables in a database, we can create some fairly rich applications!


; extconfig.conf
sippeers => driver,database[,table]

; extconfig.conf
sippeers => odbc,asterisk,ast_sipfriends

To also load our SIP users from the database, we would define the sipusers object like so:

sipusers => odbc,asterisk,ast_sipfriends


;IVR /etc/extension.conf
[aa_menu]
exten => s,1,Answer()
exten => s,n(menu_beginning) , Bckground(main-menu)
exten => s,n,WaitExten(5)
exten => s,n,Hangup()

exten => 1,1,Queue(sales)
exten => 2,1,Queue(support)
exten => 3,1,Directory()
exten => 0,1,Dial(Sip/phone-2) ; in touch with an operator

exten => i,1,Playback(invalid)  ; when operator digit an unvalid number
exten => i,n,Goto(s,menu_beinning)

exten => t,1,Playback(vm-sorry) ; when operator doesn t digit anthing
exten => i,n,Goto(s,menu_beinning)

include => phones

Read()+ GotoIf

Text to Speech
  -Cepstral

Automatic Speech Recognition(ASR)
  -LumenVox
  -Vestec    

See and How to Install and Configure a Digium TE13x Single-Span T1/E1 Card