Sunday, April 11, 2010

17 Steps to Openwrt Setup With Asterisk 1.4 on WRTSL54GS or Similar Routers - 30 Minutes

This is my recent experience in getting Asterisk 1.4 on WRTSL54GS routers. It is much easier than my previous installations on the routers.

We will go from the scratch in getting the router running in Openwrt and in Asterisk.


Step 1: Select the right image of Openwrt for your router.
Step 2: Telnet into the router with root and empty password.
Step 3:  Change password with passed command and exit.
Step 4: Login to router with SSH login.
Step 5: Install the latest Stable webif(2) from xwrt.
Step 6: Reboot and Login to router from the browser. (This is to tweak some settings if you want)
Step 7:  ipkg install  kmod-usb-uhci kmod-usb2 kmod-usb-storage kmod-ext3 fdisk e2fsprogs
Step 8: Format the external USB Disk to ext3 file system you don't need multipartition, single partition is enough.
Step 9: Attach usb disk to the router
Step 10: Mount the USB Disk to /opt directory. Even if it is already automounted to different directory you can mount it to different directory too. Use the following command to do it.
           mount -t ext3 -o noatime /dev/scsi/host0/bus0/target0/lun0/part1 /opt & Add it to the Startup script using the webif from browser.
Step 11: Reboot.
Step 12: Let us install additional softwares to the USB Disk. Poor manufacturers gave us with only MB of memory in the routers. Let us add 2GB of data to it. :)
Step 13: wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O - | tr -d '\r' > /tmp/optware-install.sh
Step 14: sh /tmp/optware-install.sh
Step 15: Let us install asterisk and additional voice files to
               /opt/bin/ipkg-opt install asterisk14-core-sounds-en-alaw asterisk14-core-sounds-en-g729 asterisk14-core-sounds-en-gsm asterisk14-core-sounds-en-ulaw asterisk14-extra-sounds-en-alaw asterisk14-extra-sounds-en-g729 asterisk14-extra-sounds-en-gsm asterisk14-extra-sounds-en-ulaw asterisk14-moh-freeplay-alaw asterisk14-moh-freeplay-g729 asterisk14-moh-freeplay-gsm asterisk14-moh-freeplay-ulaw asterisk14 asterisk14-gui libogg radiusclient-ng sqlite2 unixodbc iksemel net-snmp

Step 16: To the Startup Script Mount the USB Disk and startup asterisk.

/opt/etc/init.d/S99Asterisk:
#!/bin/sh
if [ -f /opt/var/run/asterisk.pid ] ; then
  kill `cat /opt/var/run/asterisk.pid`
else
  killall asterisk
fi
rm -f /opt/var/run/asterisk.pid
umask 077
/opt/sbin/asterisk

Step 17: Configure your voip clients and Start Making Calls.

Friday, March 26, 2010

Cache on IIS 7 with SugarCRM Windows Server 2008

If you are planning to run Cache enabled on SugarCRM with II7 then you will face weird issues. IIS caches the php pages and serve the same content to different users. With that you can see other person's userid on your pages, that is not coming from SugarCRM that is coming from IIS Cache.

It happened in Windows 2008 Server.

The only option as of now is to disable IIS Cache so all pages will be generated directly from php.

Thursday, January 14, 2010

Expectations on Google Phone

Google recently released NexusOne which is total crap to my expectations. I was so eager to get Gmail Account when they introduce gmail and most of the Google products eventhough it is over the edge on consumer privacy.

My expectations on Google as a phone is:

1. Free Phone Calls without any contract binding
2. Free Phone
3. Free Data Connection
4. Make money with advertisement.

Make open to applications free to air services and the tons which a mobile can provide.

Sunday, December 6, 2009

Cisco 7960 Complete Phone Configuration

I love cisco phones not for its name, but for the technology and way it works. The pain for an individual users is configuration the phone. Below is one of the instance where I felt the pain.

During the cleanup of the house we just removed the power and connect it again, it happens to one of the bug with the phone saying "TFTP Timeout" and did not proceeed further and not even allowed to change the tftp serverip or name. That is a shame on Cisco's QA.

In its documentation to resolve this issue (the link in cisco is outdated) it need the following to resolve it.

Add an option 150 to the dhcp server and upload the configuration with a tftp server to be fetched by the phone.
If you say this to a normal user of the phone see how things will be. Most of use non modifiable router in this case see the pain of it. Fortunately, I owned the openwrt router. (Linksys WRTSL54GS) and I can explain how that worked.

You need to have dnsmasq installed in your router.

Add the following line to dnsmasq.conf to reflect the option,

dhcp-option=150,192.168.1.235,192.168.1.235

Option 150 says that your tftp server is running on the IP.

my complete /etc/dnsmasq.conf reflects the following,



# filter what we send upstream
domain-needed
bogus-priv
filterwin2k
localise-queries

# allow /etc/hosts and dhcp lookups via *.lan
local=/lan/
domain=kans
expand-hosts
no-negcache
resolv-file=/tmp/resolv.conf.auto

# enable dhcp (start,end,netmask,leasetime)
dhcp-authoritative
dhcp-range=eth0,192.168.1.100,192.168.1.250,255.255.0.0,12h
dhcp-range=eth2,192.168.2.100,192.168.2.250,255.255.0.0,12h
dhcp-leasefile=/tmp/dhcp.leases

# use /etc/ethers for static hosts; same format as --dhcp-host
#  
read-ethers

# other useful options:
# default route(s): dhcp-option=3,192.168.1.1,192.168.1.2
#    dns server(s): dhcp-option=6,192.168.1.1,192.168.1.2
dhcp-option=150,192.168.1.235,192.168.1.235


If you are using windows based DHCP server, you can set the option 150 and enter the IP address of your tftp server.

Place the following files with the contents as mentioned below in the tftp server,

XMLDefault.cnf.xml
SIPDefault.cnf
SIP000D28083907.cnf
SEP000D28083907.cnf.xml
P003-8-12-00.sbn
P003-8-12-00.bin
P0S3-8-12-00.sb2
P0S3-8-12-00.loads
OS79XX.TXT
CTLSEP000D28083907.tlv

XMLDefault.cnf.xml:






ity="0">


2000

2427
2428







P0S3-8-12-00
P0S3-8-12-00






 


SIPDefault.cnf:



image_version: "P0S3-8-12-00"
network_media_type : Auto
network_port2_type : Hub/Switch
dscpForAudio : 184
tftp_cfg_dir : "./"
phone_password : "cisco"
phone_prompt : ">>"
language : english
sntp_mode : DirectedBroadcast
sntp_server : 0.north-america.pool.ntp.org
time_zone : MST
dst_offset : 1
dst_start_month : Mar
dst_start_day : 2
dst_start_day_of_week : Sun
dst_start_week_of_month : 1
dst_start_time : 02
dst_stop_month : Nov
dst_stop_day : 1
dst_stop_day_of_week : Sun
dst_stop_week_of_month : 1
dst_stop_time : 2
dst_auto_adjust : 1
time_format_24hr : 1
date_format : M/D/Y
nat_enable : 0
nat_address : UNPROVISIONED
voip_control_port : 5060
start_media_port : 16384
end_media_port : 32766
sync : "1"
xml_card_dir : ""
xml_card_file : "CARD.XML"
telnet_level : 2
services_url : ""
directory_url : ""
logo_url : ""
http_proxy_addr : UNPROVISIONED
http_proxy_port : 80
garp_enable : 0
enable_vad : 0
dial_template : ""
callerid_blocking : 0
anonymous_call_block : 0
autocomplete : 1
messages_uri : "*89"
dnd_control : 0
preferred_codec : g711ulaw
dtmf_outofband : avt
dtmf_avt_payload : 101
dtmf_db_level : 4
dtmf_inband : 0
proxy1_address : "192.168.251.2"
proxy2_address : ""
proxy3_address : ""
proxy4_address : ""
proxy5_address : ""
proxy6_address : ""
proxy1_port : 5060
proxy2_port : 5060
proxy3_port : 5060
proxy4_port : 5060
proxy5_port : 5060
proxy6_port : 5060
sip_retx : 10
sip_invite_retx : 6
timer_t1 : 500
timer_t2 : 4000
timer_invite_expires : 180
timer_register_expires : 3600
proxy_register : 1
proxy_backup : ""
proxy_emergency : ""
proxy_backup_port : 5060
proxy_emergency_port : 5060
outbound_proxy : "192.168.251.2"
outbound_proxy_port : 5060
nat_received_processing : 0
mwi_status : 0
call_waiting : 1
user_info : ""
cnf_join_enable : 1
remote_party_id : 1
semi_attended_transfer : 0
transfer_onhook_enabled : 0
call_hold_ringback : 0
stutter_msg_waiting : 0
cfwd_url : ""
call_stats : 0
auto_answer : 0
local_cfwd_enable : 1
timer_register_delta : 5
sip_max_forwards : 70
rfc_2543_hold : 0
version_stamp : ""
timer_keepalive_expires : 120
connection_monitor_duration : 120 



SIP000D28083907.cnf:


phone_label="Kans Global Phone"

# SIP Configuration Generic File 

# Line 1 appearance
line1_name: "12345"
line2_name: ""
line3_name: ""
line4_name: ""
line5_name: ""
line6_name: ""

line1_authname: "12345"
line2_authname: ""
line3_authname: ""
line4_authname: ""
line5_authname: ""
line6_authname: ""

line1_password: "12345"
line2_password: ""
line3_password: ""
line4_password: ""
line5_password: ""
line6_password: ""

line1_displayname: "12345"
line2_displayname: ""
line3_displayname: ""
line4_displayname: ""
line5_displayname: ""
line6_displayname: ""
line7_displayname: ""

line1_shortname: "Kans Phone"
line2_shortname: ""
line3_shortname: ""
line4_shortname: ""
line5_shortname: ""
line6_shortname: ""

speed_label2 : ""
speed_line2 : ""
speed_label3 : ""
speed_line3 : ""
speed_label4 : ""
speed_line4 : ""
speed_label5 : ""
speed_line5 : ""
speed_label6 : ""
speed_line6 : "" 

messages_uri: "*86"

####### New Parameters added in Release 3.0 ######

# Phone Prompt (The prompt that will be displayed on console and telnet)
phone_prompt:   "Kans Phone"      ; Limited to 15 characters (Default - SIP Phone) 


# User classifcation used when Registering [ none(default), phone, ip ]
user_info: none




SEP000D28083907.cnf.xml:





P0S3-8-12-00



OS79XX.TXT:
P0S3-8-12-00

CTLSEP000D28083907.tlv:
Empty File

That is all. It took an hour for me to figure this out.

Monday, October 26, 2009

utils.c broken pipe error - Asterisk or Application error? Fix

I had debated myself whether it could be asterisk or application error. I'm trying to write something to the receiver and the receiver already closed my acceptance.

Should I need to produce an error or not?

To sort this problem if you have certain delay (like sleep or usleep to .5 secs) to receive the data from Asterisk you are fine. Any scripts or remote manager sockets calling this need to wait for the same to get this error go away.

sleep(.5); // or if it can take only integers you can have sleep(1);
Make sure you consider this time when handling call.

Alternatively if you want to get the error to ignore, you can edit utils.c and comment the line producing this error. Also keep in mind when you have errors with file or socket, it will get ignored.

Hope it helps !

Wednesday, October 14, 2009

Unique BootID in Linux

# cat /proc/sys/kernel/random/boot_id
91cbd9c4-8a68-4d14-8193-8486417410d1

Gives you the random unique boot for every boot. If you application would like to see whether you system has rebooted or not, you can check with this value.

Hope it helps.

UUID LIBUUID GUID in linux

Generating UUID in linux is much easier than having an user space app to create it.
It is patched to the latest kernel of linux.

Try,

cat /proc/sys/kernel/random/uuid
d9083201-9574-4ea2-a4fc-9b8ebf9a44e4

on your linux machine. You will get randomly generated number.

Hope it helps.