connecting a Cisco 7960 IP Phone to Asterisk

Posted by Julian Dunn on May 25, 2006
Telephony

(Don’t worry, the summaries from the 2nd day of BSDCan are coming. I’m 1/4 of the way through, but I got distracted by the following toy!)

I borrowed a Cisco 7960 IP phone from work to test the feasibility of making the existing telephony infrastructure operate with Asterisk instead of Call Manager. To do this, I had to first convert the phone’s firmware from the factory SCCP to SIP. (I could have tried to use Asterisk’s Skinny support, but I figured SIP is more widely supported and I also wanted to check out Cisco’s SIP firmware)

Conceptually this proceeds as follows:

  1. Set up DHCP server to boot the phone and instruct it what TFTP server to use
  2. Set up TFTP server and load it with the SIP firmware, as well as some helper files to ease the transition (files that the SCCP firmware would normally look for to load the second-stage bootloader)
  3. Add both default (SIPDefault.cnf) and phone-specific (SIP<mac-address>.cnf) configuration files to the TFTP server to tell the phone how to register itself to Asterisk
  4. Configure sip.conf in Asterisk to reflect the same settings

I was unfortunately beset with some network problems which hindered my progress. Originally I had plugged the phone into an Aironet PoE injector, which was then plugged into a switch, which was 25 feet away from another switch/gateway combination. The TFTP/DHCP server was plugged into the latter, and for some reason ARP replies weren’t getting back to the phone. Eventually I ended up just plugging the Aironet and phone into the same switch as the TFTP/DHCP server.

Anyway, I configured ISC DHCPD as follows (MAC addresses and IPs changed to protect me):

option cisco-etherboot-server code 150 = ip-address;
.
.
.
host c7960 {
        hardware ethernet 00:16:46:C0:FF:EE;
        fixed-address 10.10.10.14;
        option host-name "SIP001646C0FFEE";
        option cisco-etherboot-server 10.10.10.1;
        option tftp-server-name "10.10.10.1";
        option arp-cache-timeout 600;
}

Older SCCP firmware used the custom DHCPD option 150 to find the TFTP server. Since I wasn’t sure which firmware I had on the phone, I decided to play it safe and use both option 150 and the newer tftp-server-name option in the lease.

On the TFTP server, one can unpack the firmware downloaded from Cisco (sorry, you need a CCO account with a valid service contract to do this). I used the latest SIP firmware from Cisco, version 8.3, which comes in a ZIP file with the following contents:

      458  05-17-06 11:02   P0S3-08-3-00.loads
   748980  05-17-06 10:46   P0S3-08-3-00.sb2
       15  05-17-06 10:48   OS79XX.TXT
   129852  05-17-06 10:58   P003-08-3-00.bin
   130256  05-17-06 11:01   P003-08-3-00.sbn

Unpack this in the root of your TFTP server. The OS79XX.TXT tells the 79xx series phones what .bin file to load (minus the extension); in this case, it just contains the string P0S3-08-3-00. My understanding is that this is the Universal Application Loader (bootloader).

You also need to create a file called XMLDefault.cnf.xml in this directory. Because the phone is still booting a SCCP firmware, it needs a file which will tell it what firmware to load into memory. I customized the one found on the voip-info page to point to the correct firmware (again, without the extension)

If you start the TFTP server now and boot the phone, it will go and flash itself using the SIP firmware and come up as an unprovisioned SIP device. (It may say "Application Protocol Invalid" because we haven’t configured the SIP*.cnf files yet.) You can tell that it’s running the SIP firmware from the SIP logo in the top right hand corner.

Now we need to configure the SIPDefault.cnf and SIP001646C0FFEE.cnf files on the TFTP server to tell the phone how to register itself with Asterisk. SIPDefault.cnf contains system-wide registration parameters, so don’t put device-specific information in there like usernames, passwords, etc. unless you want weird things happening. Use your system administrator’s discretion as to where things should go. I have the following SipDefault.cnf:

proxy1_address: "ast01.dev.rimode.ca"            ; Can be dotted IP or FQDN
proxy2_address: ""              ; Can be dotted IP or FQDN
proxy3_address: ""              ; Can be dotted IP or FQDN
proxy4_address: ""              ; Can be dotted IP or FQDN
proxy5_address: ""              ; Can be dotted IP or FQDN
proxy6_address: ""              ; Can be dotted IP or FQDN

proxy_register: 1

messages_uri:   "500"

phone_password: "cisco" ; Limited to 31 characters (Default - cisco)

sntp_server:    10.10.10.1
time_zone:      EST

dial_template: DIALPLAN

The proxyN_address variables are the Asterisk servers you wish to register against. I've also configured messages_uri to be extension 500, so that when one presses the Messages button on the phone, it just dials extension 500. Finally I've configured the default SNTP server, and also set up a dial template (which I'll address near the end of this entry.)

In the SIP001646C0FFEE.cnf I have the following (replaced with bogus values of course):

image_version: P0S3-08-3-00

#
# Sip Config for Extension: 201
#

 # Line 1 Setup
line1_name: "scott"
line1_authname: "scott"
line1_shortname: "201"
line1_password: "tiger"
line1_displayname: "Larry Ellison"; # Line 1 Display Name (Display name to use for SIP messaging)

 # Line 2 Setup
line2_name: "scott"
line2_authname: "scott"
line2_shortname: "201"
line2_password: "tiger"
line2_displayname: "Larry Ellison"; # Line 2 Display Name (Display name to use for SIP messaging)

# Phone Label (Text desired to be displayed in upper right corner)
phone_label: "Larry Ellison" ; Has no effect on SIP messaging

# Phone Password (Password to be used for console or telnet login)
phone_password: "cisco" ; Limited to 31 characters (Default - cisco)

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

telnet_level: 2

Since SIP lets you specify credentials as simply a username/password combination, there's no real reason to involve the extension # in this configuration; I use it merely to label the lines on the phone. But the shortnames could just as easily say "Line 1" and "Line 2". (Extensions really only come into play in the dialplan.)

You can find all the available configuration parameters in the Cisco SIP IP Phone Administrator Guide, Versions 6.x and 7.x available on Cisco's website. I don't know why there is no corresponding document for version 8.x of the SIP firmware, but I imagine that eventually it too will show up.

Finally, you need to configure sip.conf on the Asterisk side and reload Asterisk. Just configure it like any other SIP device:

[scott]
type=friend
host=dynamic
dtmfmode=rfc2833
nat=no
username=scott
secret=tiger
context=internal         ; dump users into this context by default
canreinvite=no
callerid="Larry Ellison"

One oddity with the SIP firmware is that unlike the Skinny firmware, it won't dial anything unless you press the Dial softkey. To get the phone to do things immediately when you match a certain dialing pattern, you need a dial_template file on the TFTP server. As you saw in my SIPDefault.cnf, I called it DIALPLAN.xml. It too must reside in the root of the TFTP server, and its format too is documented in the Cisco SIP IP Phone Adminstrator Guide. I have the following contents:

<DIALTEMPLATE>
  <TEMPLATE MATCH="2.." TIMEOUT="0"/>
  <TEMPLATE MATCH="500" TIMEOUT="0"/>
  <TEMPLATE MATCH="91.........." TIMEOUT="0"/>
  <TEMPLATE MATCH="9.........." TIMEOUT="0"/>
</DIALTEMPLATE>

This XML snippet instructs the phone to not wait at all when it matches a dialing pattern. The dialing patterns I have set up for immediate action are the internal extensions (2xx), Comedian Mail (500), and any local or long-distance calls.

And that's about it! I still want to play with getting the Directory and Services buttons to work, and maybe downloading some custom ring tones to the phone, but these seem pretty trivial (except for the Services, where I'd have to write a CGI that spits out Cisco-compliant XML). I must add that the sound quality on the Cisco 7960 is excellent; I had a 45-minute conversation with my girlfriend and it sounded just like a regular analog handset (except for the echo cancellation being a bit wonky near the beginning of the conversation). It's too bad that these phones are nearly $700 apiece!