Asterisk - the open source soft PBX (MIPSel)

Originally by Scotty from linkstationwiki.org

Building/Running Asterisk on Linkstation
This article describes how I built and installed Asterisk - the open source soft PBX - on a Linkstation. I am a Linux newbie - so please forgive me. I have a MIPS LSII and I've installed the 052b Openlink firmware as described elsewhere. Previously I have installed MySQL/Apache and PHP as described on this site. If you've done that - then the somewhat terse description below will make perfect sense. As a disclaimer, this little lot took me over a day to figure out - and I haven't been back and retraced my steps - so I appologise if some of the following contains errors - but if nothing else, it'll save you some time.

Job1
Create a symbolic link in /usr/bin to /bin/awk (because the Asterisk build system expects it there - although I guess you could also change the build system instead) cd /usr/bin ln -s /bin/awk awk

Job2
Download and build the libcurl libraries (Asterisk will use them)

* Download the tar.gz from http://curl.netmirror.org/libcurl/

* Unpack it somewhere sensible

* Do the usual configure/make/make install (I used the same scheme proposed in the Apache and MySQL articles and installed it into /mnt/hda/opt/libcurl using the --prefix parameter on ./configure)

* Once built, create a symbolic link to curl-config in /bin

* cd /bin

* ln -s /mnt/hda/opt/libcurl/bin/curl-config curl-config

* Copy the headers and libraries to the 'proper' place

* copy the /mnt/hda/opt/libcurl/include/curl directory to /usr/include (resulting in /usr/include/curl)

* copy the contents of /mnt/hda/opt/libcurl/lib to /usr/lib

* NB: Don't know if there isn't a more elegant way to add the curl include/lib directories to the 'path' for compilation (in Windows you would simply update the INCLUDE and LIB environment vars!)

Job3
Download the Asterisk source (1.4.2 at time of writing) from http://www.asterisk.org

* No need for Zaptel and Libpri stuff (you'll not fit a telephony card into a Linkstation ;-)

* Unpack it somewhere sensible (/mnt/hda/share/asterisk)

'''* Next there are a couple of modules that I just couldn't get to build - loads of assembler stuff - so don't build them - this results in some limitations detailed at the end - basically we are just not building the GSM and LPC10 codecs. Edit the code makefile (/mnt/hda/share/asterisk/codec/makefile) and comment out the following (add # to start of line)'''


 * 1) $(LIBGSM):
 * 2) 	$(MAKE) -C gsm lib/libgsm.a
 * 3) $(LIBLPC10):
 * 4) 	$(MAKE) -C lpc10 all
 * 5) codec_gsm.so: codec_gsm.o $(LIBGSMT)
 * 6) 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBGSM)
 * 7) codec_lpc10.so: codec_lpc10.o $(LIBLPC10)
 * 8) 	$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(LIBLPC10) -lm

* Now just hit make and wait for an hour...(notice how we don't need configure)

* cd /mnt/hda/share/asterisk

* make

* Assuming it builds ok - you then need to install it

* make install

Configuring Asterisk
Now it's all built, you can configure it up for a couple of SIP phones. You are now entering the realm of Asterisk config - so I recommend you take a look at a few of the following links when you get into trouble.

http://www.voip-info.org http://www.asteriskdocs.org/modules/tinycontent/content/docbook/current_v1/docs-html/book1.html http://www.asteriskdocs.org/modules/tinycontent/content/docbook/internals/docs-html/book1.html http://www.asteriskguru.com/tutorials/

Anyway, we need to create 3 config files in /etc/asterisk as follows:

sip.conf
[general] context=default disallow=all allow=alaw dtmfmode=rfc2833 context=from-sip [1000] type=friend secrect=password host=dynamic [1001] type=friend secret=password host=dynamic

extensions.conf
[general] [globals] [default] [from-sip] exten => _[1-9].,1,Dial(SIP/${EXTEN})

modules.conf
[modules] autoload=no load => res_features.so ; Call Parking Resource load => res_indications.so ; Indications Configuration load => res_musiconhold.so ; Music On Hold Resource load => pbx_config.so ; Text Extension Configuration Requires N/A load => pbx_functions.so ; Builtin dialplan functions - Requires N/A load => pbx_loopback.so ; Loopback Dialplan Switch - Requires N/A load => pbx_realtime.so ; Realtime Dialplan Switch - Requires N/A load => pbx_spool.so ; Outgoing Spool Support Requires - N/A load => func_callerid.so ; Gets or sets Caller*ID data on the channel. - Requires ? load => func_enum.so ; ENUMLOOKUP and TXTCIDNAME functions - Requres ? load => func_uri.so ; URI encode/decode functions - Requires ? load => chan_features.so ; Provides summary information on feature channels- Requires N/A load => chan_local.so ; Show status of local channels- Requires N/A load => chan_sip.so ; Session Initiation Protocol (SIP) - Requires res_features.so load => codec_alaw.so ; A-law Coder/Decoder - Requires N/A load => format_pcm_alaw.so ; Raw aLaw 8khz PCM Audio support - Requires N/A load => app_dial.so ; Dialing Application - Requires res_features.so, res_musiconhold.so load => app_softhangup.so ; Hangs up the requested channel - Requires N/A

Now you can run it...just type:

/usr/sbin/asterisk -cvvvvvvv

...there you have it - Asterisk is now running and configured for 2 SIP extensions 1000 and 1001 that can dial each other. Now you need some SIP phones to register with it and off you go - I'll let you find those. To do some of the more advanced stuff in Asterisk, you will need to specifically load the necessary modules in modules.conf - I have deliberately only loaded those 'important' (to me!) ones.

You should be able to hook up your Linkstation PBX to an internet telephony provider and use it like a 'proper' PBX - it's got voicemail and IVR functionality etc. That's for another article.

Oh and those limitations - well I couldn't figure out how to build the GSM codec (see http://linkstationwiki.org/forum/3_672_0.html) - so that causes problems when you try to get Asterisk to play any IVR type prompts to the caller. This is not a show stopper, and I think you can rerecord the prompts in PCM (ALAW) and it should work - although I haven't tried it. It's a bit of a shame, cos Asterisk comes with a load of prompts out the box...oh well.