Saturday, December 22, 2012

How To Cross Compile Asterisk and Run in Embedded System (Latest 1.8.19 Version)

How To Cross Compile Asterisk and Run in Embedded System (Latest 1.8.19 Version)

by cawan (cawan[at]ieee.org or chuiyewleong[at]hotmail.com)

on 12/12/2012

Asterisk is a very useful tool in constructing software based PABX server to manage
a VoIP system. From the perspective of embedded system designer, it is really meaningful
to run the asterisk in embedded platform to build a personal VoIP system in reducing
the cost being incurred by making international calls while traveling around the world.
In addition, by owning a personal VoIP system, the security and voice quality of our
private conversation can be improved significantly. On the other hand, from the
perspective of embedded hacker, the small box with asterisk running is an ideal
platform to perform spoofing of the real PABX server. Besides, with additional FXO
interface, it is possible to hack an automation system as well as the door access
system by abusing the DTMF signal. Well, those are all about the applications of
asterisk in embedded platform, but we should focus in cross compiling asterisk to run
in embedded system in this paper. The embedded platform that we are going to use is
MIPS32 24k, 500MHz. Let's start to download the most recent copy of asterisk source
code from http://downloads.asterisk.org/pub/telephony/asterisk/.

Host:# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz
...
...
Host:# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current-patch.gz
...
...
Host:# ls
asterisk-1.8-current-patch.gz  asterisk-1.8-current.tar.gz
Host:# tar xzvf asterisk-1.8-current.tar.gz
...
...
Host:# gunzip asterisk-1.8-current-patch.gz
Host:# ls
asterisk-1.8.19.0  asterisk-1.8-current-patch  asterisk-1.8-current.tar.gz
Host:# cd asterisk-1.8.19.0/
Host:# patch -p0 < ../asterisk-1.8-current-patch
The next patch would delete the file asterisk-1.8.18.0-summary.txt,
which does not exist!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
The next patch would delete the file asterisk-1.8.18.0-summary.html,
which does not exist!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
1 out of 1 hunk ignored
patching file build_tools/make_version
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
...
...
Apply anyway? [n]
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file contrib/scripts/ast_tls_cert.rej
patching file contrib/scripts/autosupport
Reversed (or previously applied) patch detected!  Assume -R? [n]
Apply anyway? [n]
Skipping patch.
2 out of 2 hunks ignored -- saving rejects to file contrib/scripts/autosupport.rej
Host:#

Well, it seems the patch has been applied to the current version of the asterisk source.
We just ignore it first. Let's start to cross compile it now.

Host:# ./configure --host=mips-linux-gnu --target=mips-linux-gnu \
CC="mips-linux-gnu-gcc -EL" LD="mips-linux-gnu-ld -EL" AR="mips-linux-gnu-ar" \
CXX="mips-linux-gnu-g++ -EL"
...
...
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for initscr in -lcurses... no
checking for initscr in -lncurses... no
configure: error: *** termcap support not found (on modern systems, this typically
means the ncurses development package is missing)
Host:#

Unfortunately, the libtermcap makes trouble again... Since we already have experience
in cross compiling libtermcap, we try to use libncurses this time. Let's start.

Host:# wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz
...
...
Host:# tar xzvf ncurses-5.9.tar.gz
...
...
Host:# cd ncurses-5.9
Host:# ./configure --host=mips-linux-gnu --target=mips-linux-gnu \
CC="mips-linux-gnu-gcc -EL" LD="mips-linux-gnu-ld -EL" CXX="mips-linux-gnu-g++ -EL"
...
...
Host:# make
...
...
Host:# make install DESTDIR=$PWD/cawanmipsncurses
...
...
Host:# cd cawanmipsncurses/
Host:# ls
usr
Host:# cd usr/
Host:# ls
bin  include  lib  man  share
Host:# cd lib
Host:# ls
libcurses.a  libform_g.a  libmenu_g.a   libncurses++.a  libpanel.a    terminfo
libform.a    libmenu.a    libncurses.a  libncurses_g.a  libpanel_g.a
Host:# cd ..
Host:# pwd
/home/smp383/mips-4.3/bin/asterisk/testasterisk/ncurses-5.9/cawanmipsncurses/usr
Host:#

Nice, we have libncurses right now. Let's cross compile the asterisk again by specifying
the path of libncurses explicitly.

Host:# make distclean
...
...
Host:# ./configure --host=mips-linux-gnu --target=mips-linux-gnu CC="mips-linux-gnu-gcc -EL" \
LD="mips-linux-gnu-ld -EL" AR="mips-linux-gnu-ar" CXX="mips-linux-gnu-g++ -EL" \
--with-ncurses=/home/smp383/mips-4.3/bin/asterisk/testasterisk/ncurses-5.9/cawanmipsncurses/usr
...
...
checking for xml2-config... no
configure: *** XML documentation will not be available because the 'libxml2' development package is missing.
configure: *** Please run the 'configure' script with the '--disable-xmldoc' parameter option
configure: *** or install the 'libxml2' development package.
Host:# make
make: -F.: Command not found
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
/bin/sh: Illegal option -
****
**** The configure script must be executed before running 'make'.
****               Please run "./configure".
****
make: *** [makeopts] Error 1

Well, it seems we should add --disable-xmldoc in configure tool. Let's try again.

Host:# make distclean
...
...
Host:# ./configure --host=mips-linux-gnu --target=mips-linux-gnu CC="mips-linux-gnu-gcc -EL" \
LD="mips-linux-gnu-ld -EL" AR="mips-linux-gnu-ar" CXX="mips-linux-gnu-g++ -EL" \
--with-ncurses=/home/smp383/mips-4.3/bin/asterisk/testasterisk/ncurses-5.9/cawanmipsncurses/usr \
--disable-xmldoc
...
...
configure: Package configured for:
configure: OS type  : linux-gnu
configure: Host CPU : mips
configure: build-cpu:vendor:os: i686 : pc : linux-gnu :
configure: host-cpu:vendor:os: mips : unknown : linux-gnu :
configure: Cross Compilation = YES
Host:# make
...
...
checking for tgetent in -ltermcap... no
checking for tgetent in -ltinfo... no
checking for tgetent in -lcurses... no
checking for tgetent in -lncurses... no
configure: error: termcap support not found
make[1]: *** [editline/libedit.a] Error 1
make: *** [main] Error 2
Host:#

Unfortunately, error again in generating editline/libedit.a archive. Let's check.

Host:# find . -iname editline
./main/editline
Host:# cd main/editline/
Host:# nano configure

Let's have a look to the configure file. Since we already passed the libncurses path
to the main configure tool, so, we can try to bypass the check error directly and see
the libedit.a will be generated or not. At lines around 1282, we can see something
like this.

if { (eval echo configure:1282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && \
test -s conftest${ac_exeext}; then
  rm -rf conftest*
  eval "ac_cv_lib_$ac_lib_var=yes"
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  rm -rf conftest*
  eval "ac_cv_lib_$ac_lib_var=no"
fi

When libncurses is missing, the "ac_cv_lib_$ac_lib_var" will set to "no". Now, let
us change it to "yes". So, after the modification, it should look something like
this.

if { (eval echo configure:1282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && \
test -s conftest${ac_exeext}; then
  rm -rf conftest*
  eval "ac_cv_lib_$ac_lib_var=yes"
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  rm -rf conftest*
  eval "ac_cv_lib_$ac_lib_var=yes"
fi

Let us start the cross compilation again.

Host:# pwd
/home/smp383/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/main/editline
Host:# cd ..
Host:# cd ..
Host:# make
...
...
 +--------- Asterisk Build Complete ---------+
 + Asterisk has successfully been built, and +
 + can be installed by running:              +
 +                                           +
 +                make install               +
 +-------------------------------------------+
Host:#

Excellent, the cross compilation process completed. Let us verify the libedit.a being
generated.

Host:# mkdir ./test
Host:# cd test
Host:# cp ../main/editline/libedit.a .
Host:# mips-linux-gnu-ar t libedit.a
editline.o_a
fgetln.o_a
vis.o_a
unvis.o_a
strlcpy.o_a
strlcat.o_a
history.o_a
tokenizer.o_a
readline.o_a
Host:# mips-linux-gnu-ar x libedit.a
Host:# ls
editline.o_a  fgetln.o_a  history.o_a  libedit.a  readline.o_a  strlcat.o_a 
strlcpy.o_a  tokenizer.o_a  unvis.o_a  vis.o_a
Host:# file editline.o_a
editline.o_a: ELF 32-bit LSB relocatable, MIPS, MIPS32 rel2 version 1 (SYSV), not stripped
Host:#

Nice, the object file being generated are really those we are looking for. Let's continue
our cross compilation process.

Host:# cd ..
Host:# make install DESTDIR=$PWD/cawanasterisk
...
...
 +---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 +                make samples               +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +               make progdocs               +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+
Host:# ls ./cawanasterisk/etc/asterisk/
Host:#

Well, still no any default configuration files found. Let's make samples.

Host:# make samples DESTDIR=$PWD/cawanasterisk
...
...
Installing file phoneprov/000000000000.cfg
Installing file phoneprov/000000000000-directory.xml
Installing file phoneprov/000000000000-phone.cfg
Installing file phoneprov/polycom_line.xml
Installing file phoneprov/polycom.xml
Installing file phoneprov/snom-mac.xml
Host:# ls -l ./cawanasterisk/etc/asterisk/
total 796
-rw-r--r-- 1 root root   140 2012-12-12 18:37 adsi.conf
-rw-r--r-- 1 root root  2636 2012-12-12 18:37 agents.conf
-rw-r--r-- 1 root root  2904 2012-12-12 18:37 ais.conf
-rw-r--r-- 1 root root  2084 2012-12-12 18:37 alarmreceiver.conf
-rw-r--r-- 1 root root  3498 2012-12-12 18:37 alsa.conf
-rw-r--r-- 1 root root   767 2012-12-12 18:37 amd.conf
-rw-r--r-- 1 root root  1044 2012-12-12 18:37 app_mysql.conf
-rw-r--r-- 1 root root  3254 2012-12-12 18:37 asterisk.adsi
-rw-r--r-- 1 root root  3461 2012-12-12 18:37 asterisk.conf
-rw-r--r-- 1 root root  4803 2012-12-12 18:37 calendar.conf
-rw-r--r-- 1 root root  6955 2012-12-12 18:37 ccss.conf
-rw-r--r-- 1 root root  2466 2012-12-12 18:37 cdr_adaptive_odbc.conf
-rw-r--r-- 1 root root  8381 2012-12-12 18:37 cdr.conf
-rw-r--r-- 1 root root  1617 2012-12-12 18:37 cdr_custom.conf
-rw-r--r-- 1 root root   418 2012-12-12 18:37 cdr_manager.conf
-rw-r--r-- 1 root root  2231 2012-12-12 18:37 cdr_mysql.conf
...
...
Host:#

Good, the make samples done successfully. We don't need to perform make config because
we are doing cross compilation but not going to install the asterisk locally. Now,
let's run the asterisk in MIPS environment.

tango3[~]# ifconfig eth0 192.168.1.198
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
tango3[~]# mkdir cawan
tango3[~]# mount -o nolock 192.168.1.197:/home/smp383 ./cawan
tango3[~]# cd cawan
tango3[cawan]# cd mips-4.3/bin/asterisk/
tango3[asterisk]# cd testasterisk/asterisk-1.8.19.0/cawanasterisk/
tango3[cawanasterisk]# ls
etc/ usr/ var/
tango3[cawanasterisk]# cd usr/sbin/
tango3[sbin]# ls
astcanary*     astgenkey*     rasterisk@
asterisk*      autosupport*   safe_asterisk*
tango3[sbin]# ./asterisk -h
Asterisk 1.8.19.0, Copyright (C) 1999 - 2012, Digium, Inc. and others.
Usage: asterisk [OPTIONS]
Valid Options:
   -V              Display version number and exit
   -C Use an alternate configuration file
   -G       Run as a group other than the caller
   -U        Run as a user other than the caller
   -c              Provide console CLI
   -d              Enable extra debugging
   -f              Do not fork
   -F              Always fork
   -g              Dump core in case of a crash
   -h              This help screen
   -i              Initialize crypto keys at startup
   -I              Enable internal timing if DAHDI timer is available
   -L        Limit the maximum load average before rejecting new calls
   -M       Limit the maximum number of calls to the specified value
   -m              Mute debugging and console output on the console
   -n              Disable console colorization
   -p              Run as pseudo-realtime thread
   -q              Quiet mode (suppress output)
   -r              Connect to Asterisk on this machine
   -R              Same as -r, except attempt to reconnect if disconnected
   -s      Connect to Asterisk via socket (only valid with -r)
   -t              Record soundfiles in /var/tmp and move them where they
                   belong after they are done
   -T              Display the time in [Mmm dd hh:mm:ss] format for each line
                   of output to the CLI
   -v              Increase verbosity (multiple v's = more verbose)
   -x         Execute command (implies -r)
   -X              Execute includes by default (allows #exec in asterisk.conf)
   -W              Adjust terminal colors to compensate for a light background
tango3[sbin]# ./asterisk -V
Asterisk 1.8.19.0
tango3[sbin]# ./asterisk -c -v                                             
Asterisk 1.8.19.0, Copyright (C) 1999 - 2012 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
No entry for terminal type "vt102";
using dumb terminal settings.
No 'modules.conf' found, no modules will be loaded.
Unable to open AMI configuration manager.conf, or configuration is invalid.
Asterisk management interface (AMI) disabled.
Can't find indications config file indications.conf.
 Asterisk Dynamic Loader Starting:
 Asterisk PBX Core Initializing
 Registering builtin applications:
 [Answer]
 [BackGround]
 [Busy]
 [Congestion]
 [ExecIfTime]
 [Goto]
 [GotoIf]
 [GotoIfTime]
 [ImportVar]
 [Hangup]
 [Incomplete]
 [NoOp]
 [Proceeding]
 [Progress]
 [RaiseException]
 [ResetCDR]
 [Ringing]
 [SayAlpha]
 [SayDigits]
 [SayNumber]
 [SayPhonetic]
 [Set]
 [MSet]
 [SetAMAFlags]
 [Wait]
 [WaitExten]
Could not load features.conf
Unable to open Asterisk database '/var/lib/asterisk/astdb': No such file or directory
Could not find valid ccss.conf file. Using cc_max_requests default
 Asterisk Dynamic Loader Starting:
No 'modules.conf' found, no modules will be loaded.
Asterisk Ready.
*CLI>

Well, we need to specify the path of asterisk.conf. Let's go.

tango3[sbin]# pwd            
/root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/usr/sbin
tango3[sbin]# ./asterisk -c -v -C /root/cawan/mips-4.3/bin/asterisk/testasterisk/\
asterisk-1.8.19.0/cawanasterisk/etc/asterisk/asterisk.conf
Asterisk 1.8.19.0, Copyright (C) 1999 - 2012 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
No entry for terminal type "vt102";
using dumb terminal settings.
No 'modules.conf' found, no modules will be loaded.
Unable to open AMI configuration manager.conf, or configuration is invalid.
Asterisk management interface (AMI) disabled.
Can't find indications config file indications.conf.
 Asterisk Dynamic Loader Starting:
 Asterisk PBX Core Initializing
 Registering builtin applications:
 [Answer]
 [BackGround]
 [Busy]
 [Congestion]
 [ExecIfTime]
 [Goto]
 [GotoIf]
 [GotoIfTime]
 [ImportVar]
 [Hangup]
 [Incomplete]
 [NoOp]
 [Proceeding]
 [Progress]
 [RaiseException]
 [ResetCDR]
 [Ringing]
 [SayAlpha]
 [SayDigits]
 [SayNumber]
 [SayPhonetic]
 [Set]
 [MSet]
 [SetAMAFlags]
 [Wait]
 [WaitExten]
Could not load features.conf
Unable to open Asterisk database '/var/lib/asterisk/astdb': No such file or directory
Could not find valid ccss.conf file. Using cc_max_requests default
 Asterisk Dynamic Loader Starting:
No 'modules.conf' found, no modules will be loaded.
Asterisk Ready.
*CLI>

It seems the asterisk.conf needs to be modified. Let's do it.

Host:# nano asterisk.conf

[directories](!)
astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astdbdir => /var/lib/asterisk
astkeydir => /var/lib/asterisk
astdatadir => /var/lib/asterisk
astagidir => /var/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk

Let us change it to the correct path.

[directories]  
astetcdir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/etc/asterisk
astmoddir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/usr/lib/asterisk/modules
astvarlibdir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/lib/asterisk
astdbdir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/lib/asterisk
astkeydir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/lib/asterisk
astdatadir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/lib/asterisk
astagidir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/lib/asterisk/agi-bin
astspooldir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/spool/asterisk
astrundir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/run/asterisk
astlogdir => /root/cawan/mips-4.3/bin/asterisk/testasterisk/asterisk-1.8.19.0/cawanasterisk/var/log/asterisk

Remember to remove the (!) after [directories]

Let's start the asterisk again in MIPS environment.

tango3[sbin]# ./asterisk -c -v -C /root/cawan/mips-4.3/bin/asterisk/testasterisk/\
asterisk-1.8.19.0/cawanasterisk/etc/asterisk/asterisk.conf
Asterisk 1.8.19.0, Copyright (C) 1999 - 2012 Digium, Inc. and others.
Created by Mark Spencer
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
...
...
 pbx_ael.so => (Asterisk Extension Language Compiler)
 app_readexten.so => (Read and evaluate extension validity)
 func_channel.so => (Channel information dialplan functions)
 func_volume.so => (Technology independent volume control)
 func_sysinfo.so => (System information related functions)
 func_cdr.so => (Call Detail Record (CDR) dialplan function)
 res_mutestream.so => (Mute audio stream resources)
 app_directory.so => (Extension Directory)
 pbx_spool.so => (Outgoing Spool Support)
 func_pitchshift.so => (Audio Effects Dialplan Functions)
 func_sha1.so => (SHA-1 computation dialplan function)
 res_security_log.so => (Security Event Logging)
 func_frame_trace.so => (Frame Trace for internal ast_frame debugging.)
 codec_a_mu.so => (A-law and Mulaw direct Coder/Decoder)
 app_test.so => (Interface Test Application)
 func_iconv.so => (Charset conversions)
 chan_unistim.so => (UNISTIM Protocol (USTM))
 codec_gsm.so => (GSM Coder/Decoder)
 bridge_simple.so => (Simple two channel bridging module)
 app_senddtmf.so => (Send DTMF digits Application)
 app_milliwatt.so => (Digital Milliwatt (mu-law) Test Application)
 app_chanspy.so => (Listen to the audio of an active channel)
 func_callcompletion.so => (Call Control Configuration Function)
 codec_alaw.so => (A-law Coder/Decoder)
 app_exec.so => (Executes dialplan applications)
 codec_g726.so => (ITU G.726-32kbps G726 Transcoder)
 app_morsecode.so => (Morse code)
 app_originate.so => (Originate call)
 res_clioriginate.so => (Call origination and redirection from the CLI)
 func_timeout.so => (Channel timeout dialplan functions)
 pbx_loopback.so => (Loopback Switch)
 app_cdr.so => (Tell Asterisk to not maintain a CDR for the current call)
 app_disa.so => (DISA (Direct Inward System Access) Application)
 app_voicemail.so => (Comedian Mail (Voicemail System))
 app_while.so => (While Loops and Conditional Execution)
 func_callerid.so => (Party ID related dialplan functions (Caller-ID, Connected-line, Redirecting))
 app_dictate.so => (Virtual Dictation Machine)
 app_controlplayback.so => (Control Playback Application)
 app_image.so => (Image Transmission Application)
 app_playtones.so => (Playtones Application)
 app_playback.so => (Sound File Playback Application)
 app_adsiprog.so => (Asterisk ADSI Programming Application)
 func_vmcount.so => (Indicator for whether a voice mailbox has messages in a given folder.)
 func_md5.so => (MD5 digest dialplan functions)
 bridge_softmix.so => (Multi-party software based channel mixing)
 res_limit.so => (Resource limits)
 res_realtime.so => (Realtime Data Lookup/Rewrite)
 func_db.so => (Database (astdb) related dialplan functions)
 codec_ilbc.so => (iLBC Coder/Decoder)
 chan_phone.so => (Linux Telephony API Support)
 app_privacy.so => (Require phone number to be entered, if no CallerID sent)
 func_base64.so => (base64 encode/decode dialplan functions)
 func_uri.so => (URI encode/decode dialplan functions)
 app_authenticate.so => (Authentication Application)
 app_dial.so => (Dialing Application)
 app_speech_utils.so => (Dialplan Speech Applications)
 app_record.so => (Trivial Record Application)
 codec_lpc10.so => (LPC10 2.4kbps Coder/Decoder)
 res_phoneprov.so => (HTTP Phone Provisioning)
 app_system.so => (Generic System() application)
 app_directed_pickup.so => (Directed Call Pickup Application)
 chan_oss.so => (OSS Console Channel Driver)
 func_strings.so => (String handling dialplan functions)
 func_version.so => (Get Asterisk Version/Build Info)
 app_amd.so => (Answering Machine Detection Application)
 app_read.so => (Read Variable Application)
 app_sendtext.so => (Send Text Applications)
 codec_g722.so => (ITU G.722-64kbps G722 Transcoder)
 func_audiohookinherit.so => (Audiohook inheritance function)
 func_lock.so => (Dialplan mutexes)
 func_dialgroup.so => (Dialgroup dialplan function)
 func_blacklist.so => (Look up Caller*ID name/number from blacklist database)
 app_mixmonitor.so => (Mixed Audio Monitoring Application)
 app_url.so => (Send URL Applications)
 app_forkcdr.so => (Fork The CDR into 2 separate entities)
 func_module.so => (Checks if Asterisk module is loaded in memory)
 bridge_builtin_features.so => (Built in bridging features)
 codec_adpcm.so => (Adaptive Differential PCM Coder/Decoder)
 func_cut.so => (Cut out information from a string)
 codec_ulaw.so => (mu-Law Coder/Decoder)
 app_softhangup.so => (Hangs up the requested channel)
  == Aliased CLI command 'hangup request' to 'channel request hangup'
  == Aliased CLI command 'originate' to 'channel originate'
  == Aliased CLI command 'help' to 'core show help'
  == Aliased CLI command 'pri intense debug span' to 'pri set debug 2 span'
  == Aliased CLI command 'reload' to 'module reload'
 res_clialiases.so => (CLI Aliases)
 bridge_multiplexed.so => (Multiplexed two channel bridging module)
 res_convert.so => (File format conversion CLI command)
 app_waitforsilence.so => (Wait For Silence)
 app_festival.so => (Simple Festival Interface)
 app_sms.so => (SMS/PSTN handler)
 app_waituntil.so => (Wait until specified time)
 app_mp3.so => (Silly MP3 Application)
 func_aes.so => (AES dialplan functions)
 func_enum.so => (ENUM related dialplan functions)
 app_talkdetect.so => (Playback with Talk Detection)
 func_groupcount.so => (Channel group dialplan functions)
 app_readfile.so => (Stores output of file into a variable)
 app_minivm.so => (Mini VoiceMail (A minimal Voicemail e-mail System))
 func_rand.so => (Random number dialplan function)
 app_sayunixtime.so => (Say time)
 app_verbose.so => (Send verbose output)
 func_shell.so => (Collects the output generated by a command executed by the system shell)
 app_channelredirect.so => (Redirects a given channel to a dialplan target)
 func_env.so => (Environment/filesystem dialplan functions)
 app_setcallerid.so => (Set CallerID Presentation Application)
 app_dumpchan.so => (Dump Info About The Calling Channel)
 func_math.so => (Mathematical dialplan function)
 pbx_config.so => (Text Extension Configuration)
 func_global.so => (Variable dialplan functions)
 func_logic.so => (Logical dialplan functions)
 app_getcpeid.so => (Get ADSI CPE ID)
 app_ices.so => (Encode and Stream via icecast and ices)
 func_config.so => (Asterisk configuration file variable access)
 app_db.so => (Database Access Functions)
 app_userevent.so => (Custom User Event Application)
 app_celgenuserevent.so => (Generate an User-Defined CEL event)
 app_echo.so => (Simple Echo Application)
 app_queue.so => (True Call Queueing)
Asterisk Ready.
*CLI>

Nice, the asterisk is successfully running now. Let's check the sip info.

*CLI> sip show users
Username            Secret         Accountcode      Def.Context      ACL  ForcerPort
*CLI> sip show peers
Name/username        Host         Dyn Forcerport ACL Port     Status    
0 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 0 offline]
*CLI> sip show channelstats
Peer    Call ID    Duration Recv: Pack  Lost  (%) Jitter Send: Pack  Lost  (%) Jitter
0 active SIP channels

Fine, there is no any sip extension yet. Let us create it now and restart the asterisk
again.

Host:# nano sip.conf

Go to the end of the file and append the following lines to create 2 extensions.

[101]
type=friend
secret=101
host=dynamic
context=internal
username=101
callgroup=1
pickupgroup=1

[102]
type=friend
secret=102
host=dynamic
context=internal
username=102
callgroup=1
pickupgroup=1

Then, we edit extensions.conf.

Host:# nano extensions.conf

Go to the end of the file and append the following lines.

[internal]
exten=>101,1,Dial(SIP/101,20)
exten=>102,1,Dial(SIP/102,20)

Now, let us restart the asterisk and check the sip extensions.

*CLI> sip show users
Username                   Secret           Accountcode      Def.Context      ACL  ForcerPort
101                        101                               internal         No   Yes      
102                        102                               internal         No   Yes      
*CLI> sip show peers
Name/username              Host                     Dyn Forcerport ACL Port     Status    
101/101                    (Unspecified)            D   N             0        Unmonitored
102/102                    (Unspecified)            D   N             0        Unmonitored
2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 2 offline]

Good, 2 sip extensions have been created. Let's test it by using 2 smart phones with
sip app (iSip or 3CXPhone) installed. Each smart phone registers to extension 101 and
102 respectively. Then, check the sip extensions in asterisk again.

*CLI> sip show peers
Name/username              Host                     Dyn Forcerport ACL Port     Status    
101/101                    192.168.1.3              D   N             5060     Unmonitored
102/102                    192.168.1.9              D   N             5065     Unmonitored
2 sip peers [Monitored: 0 online, 0 offline Unmonitored: 2 online, 0 offline]

Excellent, it seems both of the extensions are online right now. Let's make a call.
Yes, the callee rings and once the connection is accepted, it is ready to start a
conversation. While the conversation is running, let us check the channel statistic
in asterisk.

*CLI> sip show channelstats
Peer             Call ID      Duration Recv: Pack  Lost       (     %) Jitter Send: Pack  Lost       (     %) Jitter
192.168.1.9      .8zN5DtXR7-  00:00:22 0000000000  0000000000 ( 0.00%) 0.0000 0000000000  0000000000 ( 0.00%) 0.0000
1 active SIP channel
*CLI> sip show channels
Peer             User/ANR         Call ID          Format           Hold     Last Message    Expiry     Peer     
192.168.1.9      102              .8zN5DtXR7-g3dH  0x4 (ulaw)       No       Tx: ACK                    102      
192.168.1.3      (None)           r-9.sa-1gtndvpt  0x0 (nothing)    No       Rx: REGISTER                 
192.168.1.3      101              4d2aa9de449c20c  0x4 (ulaw)       No       Tx: ACK                    101      
3 active SIP dialogs

Nice, the conversation is shown accordingly.

pdf version:


http://www.scribd.com/doc/117698898/How-to-Cross-Compile-Asterisk-and-Run-in-Embedded-System

2 comments:

  1. Hello,
    The Article on How To Cross Compile Asterisk and Run in Embedded System is nice .It give detail information about it. Thanks for sharing the article on it. Xamarin Consulting Services

    ReplyDelete
  2. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Visit here for Penetration testing services and Software testing services

    ReplyDelete