For once, this article is not directly related to “infosec“. My blog isn’t called “/dev/random” for nothing, right? In parallel to my dayly job as an Information Security Consultant and my blogger experience at night, I’m also doing business via my own company, TrueSec (<advertising>Feel free to contact me if you’re looking for consultancy services</advertising>). For a while, I’m using OpenERP to keep track of my customers, projects, invoices and other administrative tasks. This software is a fully open source ERP (“Enterprise Resource Planning“) with many extensions. To benefit of a dedicated line and improve communications with my customers, I’m using a SIP service with a public phone number for a few days. And since today, the SIP line is connected to a good old Cisco IP phone (7940g). Honestly, it was’nt easy to configure the phone: reflash with a SIP-enabled firmware, fight with the text configuration files sent over TFTP, but… it worked! Even the ring tone and logo were customized:
The next step was to integrate the phone with an external address book. It seemed logical to integrate it with a database containing primarily all my business contacts: The OpenERP database! Let’s see how to interconnect both! The Cisco phone stores its address book in a XML file but with a limited size (I think that the limit is 32 entries for my 7940g). But it’s possible to configure the phone to make requests via a web page! Magic! How?
In the SIPDefault.cnf, add the following line (don’t forget to reboot the phone!):
#The directory_url contains a URL to the directory XML file directory_url: "http://webserver/directory.xml"
Create the file on your “webserver“:
# cat /var/www/directory.xml <CiscoIPPhoneInput> <Title>OpenERP Address Book</Title> <Prompt>Type your query...</Prompt> <URL>http://webserver/directory.php</URL> <InputItem> <DisplayName>search</DisplayName> <QueryStringParam>search</QueryStringParam> <InputFlags></InputFlags> <DefaultValue></DefaultValue> </InputItem> </CiscoIPPhoneInput>
What does it mean? When you will press the “Directories” button on the phone and then select “External Directory“, the phone will propose you to enter a query string which will be passed to the defined URL as follow:
The result of this HTTP request must be a valid XML file with the following format:
<CiscoIPPhoneDirectory> <Title>Open ERP Address Book</Title> <Prompt>Select your contact</Prompt> <DirectoryEntry> <Name>Xavier</Name> <Telephone>555-123-456</Telephone> </DirectoryEntry> </CiscoIPPhoneDirectory>
The last step is to lookup the OpenERP database for contacts and generate the XML output. How? No need to reinvent the wheel, OpenERP offers an XMLRPC API which can be used within all languages! My script is written in PHP and uses a PHP class developed to interact easily with OpenERP. Download the PHP class, download my script on a local webserver and change the OpenERP settings:
// Define your OpenERP environment $openerp_url = "http://openerp.server:80/xmlrpc/"; $openerp_db = "xxxxxx"; $openerp_user = "xxxxxx"; $openerp_pass = "xxxxxx"; $max_entries = 32;
And an example of the data returned by the script:
Enjoy this little hack! The next step will be to lookup incoming numbers to display the customer name!