/* * phonecfg.c -- Basic Cisco VoIP phone configuration generator * Author: Michael J. Tubby B.Sc. (Hons) G8TIC, mike@tubby.org * * * ABSTRACT * * A quick-and-dirty VoIP phone generator for Cisco 7940/7960 * phone configuration and firmware upgrade. * * * DESCRIPTION * * I wrote this small program when building my first sizeable * VoIP phone system for work. We purchased 20 new Cisco 7960 * phones and they all came with the base Cisco SCCP manufacturing * SCCP image (P003030202MFG if my memory serves me correctly). * * We wanted to use SIP on the phones with Asterisk - there's * been much talk about how hard it is to upgrade Cisco phones * from an early SCCP images to the later SIP images - here's a * brief description. * * Early Cisco phones run a plain binary image, later phones * run a crypto signed image. You are probably wanting to upgrade * your phone's firmware from SCCP 3.xx to SIP 7.xx firmware * which requires that the phone runs a signed image. * * Cisco's documentation is complex and in places wrong (sorry * guys) but here's what works for me! * * Upgrading is a multi-part process: * * Early SCCP -> Late SCCP -> Late SIP * * In total four re-programmings of the phone's flash: * * 1. the Universal Application Loader from SCCP 6.0(1) * 2. the SCCP firmware 6.0(1) * 3. the newer UAL from SIP firmware 7.4(0) * 4. the SIP firmware 7.4(0) * * My process uses the SEP.cnf.xml file only and * does not require OS79XX.TXT * * * SOFTWARE INSTALLATION * * There is no Makefile! Place this source file in your /tftpboot * directory and type the following: * * cc -o phoncfg phonecfg.c -lc * * to create the binary. * * To make an SCCP (Cisco) phone configuration use the following: * * ./phonecfg -c * * for example: * * ./phonecfg -c 001201EC4938 * * to make a SIP configuration file change the "-c" to "-s" * * * PERFORMING THE UPGRADE * * To upgrade your 7940/7960 do the folloing: * * a) obtain SCCP firmware 6.0(1) -- you'll find this in a * CallManager 4.0(1) installation * * b) obtain SIP fimware 7.4(0) -- you have got a Cisco support * contract, right? Good.... I don't supply firmware. * * c) Make sure you have these files in your TFTP server's boot * directory: * * -rwxr--r-- 1 root root 124592 Jan 5 2004 P00306000100.bin * -rwxr--r-- 1 root root 461 Jan 5 2004 P00306000100.loads * -rwxr--r-- 1 root root 606306 Jan 5 2004 P00306000100.sb2 * -rwxr--r-- 1 root root 124996 Jan 5 2004 P00306000100.sbn * -rwxr--r-- 1 root root 592222 Mar 10 15:44 P0S3-07-4-00.bin * -rwxr--r-- 1 root root 461 Mar 10 16:01 P0S3-07-4-00.loads * -rwxr--r-- 1 root root 592626 Mar 10 15:45 P0S3-07-4-00.sb2 * * d) Make sure that your DHCP server hands off DHCP option 66 and * option 150 as an IP address pointing at your TFTP server. In * ISC's DHCP3 server, something like: * * option cisco-callmanager code 150 = ip-address; * option tftp-server code 66 = ip-address; * * in the global section, and: * * option cisco-callmanager 192.168.144.1; * option tftp-server 192.168.144.1; * * in the appropriate LAN segment, my home LAN is 192.168.144.0/24 * * e) make the SCCP XML configuration file, thus: * * ./phonecfg -c * * f) boot the phone, wait for it to download the UAL and install it, * wait for it to download the main SCCP image and install it * * g) make the SIP XML configuration fil, thus: * * ./phonecfg -s * * h) boot the phone, wait for it to upgrade the UAL to the newer one, * then it will reboot and fetch the SIP image. * * * You'll know when you've got to the end successfully because the * phone will come up running the SIP firware and say "Unprovisioned" * * * * COPYRIGHT * * This code is released under the GNU Public Licence, please feel * free to amend it, adapt it, improve it, etc. * * * WARRANTY * * This software is provided "as is" ith no warranty of any kind. * You take full responsibility for using this software and agree * that you are supporting yourself. * If you break the sofware you get to keep all the pieces! * If you break your phone you have an expensive paper wieght! * * */ #include #define SCCP_IMAGE "P00306000100" /* SCCP image 6.0(1) */ #if 0 #define SIP_IMAGE "P0S3-07-4-00" /* SIP image 7.4(0) */ #endif #define SIP_IMAGE "P0S3-07-5-00" /* SIP image 7.5(0) */ /* * global variables */ extern char *optarg; extern int optind, opterr, optopt; extern int errno; FILE * fout; static void config_sip(char * mac) { char fn[50]; sprintf(fn, "SEP%s.cnf.xml", mac); fout = fopen(fn, "w"); if (fout) { fprintf(fout, "\n"); fprintf(fout, "%s\n", SIP_IMAGE); fprintf(fout, "\n"); fclose(fout); printf("phonecfg: wrote file: %s for SIP firmware image: %s\n", fn, SIP_IMAGE); } else { fprintf(stderr, "error: cannot write: %f for SIP config\n", fn); exit(1); } } static void config_sccp(char * mac) { char fn[50]; sprintf(fn, "SEP%s.cnf.xml", mac); fout = fopen(fn, "w"); if (fout) { fprintf(fout, "\n"); fprintf(fout, "%s\n", SCCP_IMAGE); fprintf(fout, "\n"); fclose(fout); printf("phonecfg: wrote file: %s for SCCP firmware image: %s\n", fn, SCCP_IMAGE); } else { fprintf(stderr, "error: cannot write: %f for SCCP config\n", fn); exit(1); } } /* * main() - program... yup... the bit that does the work :o) */ int main(int argc, char * argv[]) { int rc; /* * parse command line args */ while ((rc = getopt(argc, argv, "c:s:?")) >= 0) { switch (rc) { case 's': config_sip(optarg); break; case 'c': config_sccp(optarg); break; case '?': printf("phonecfg: usage:\n\n"); printf(" phonecfg -c to make a SCCP image config\n"); printf(" phonecfg -s to make a SIP image config\n"); printf("\n"); exit(0); } } }