Identifying the Correct Device Status in a RISPort Response

Author
William Bell
Vice President, Solutions and Products

A couple of weeks ago I started discussing the RISPort API and how it compares to devicelistx.asp (from my point of view, at least). So far I have found this API to be pretty handy and relatively quick.  Definitely faster than devicelistx.asp with larger data sets.  There are various lessons I am learning as I work through updating my various tools.  One of these valuable lessons is that it is very possible that the RIS response will list a device you are looking for more than once.

To understand “why”, we have to look at the structure of the response.  A snippet of an example response:

For our discussion, the key XML nodes are the item nodes, the Status node, and the TimeStamp node.  As you can see there are various item nodes (confusing I know) and they are differentiated by the attribute “type”.  The first node type of interest is “ns1:CmNode”.  As seen in the example, every CUCM node is included in the response.  In our example there is the CUCM node with the IP address of 10.10.10.7 and a second one with the IP address of 10.10.10.8.

Both nodes report status for the same IP phone (SEP001EF72A48C5).  Looking at the Status node you can see on 10.10.10.7 the phone is registered and on 10.10.10.8 the phone is unregistered.  In this example, we forced a failure on the 10.10.10.7 server (so phones failed over to 10.10.10.8) and then we resolved the failure (so that phones failed back).  So, the why is easy.  But which report should be trusted?

The answer is both are valid and you have to determine the latest news by reviewing the TimeStamp field.  Obviously doing this check manually for a potential group of a few dozen (much less a few thousand) phones is  not how one should spend their day.  I came across this while testing some tools, so it is onlyfair to show how one could do it programatically.

The first step is to submit a properly formatted RIS request and then grab the resulting XML response stream from the CUCM first node (publisher).  I use a windows ActiveXObject called “MSXML2.DOMDocument.4.0” as my XML document object holder.  You can find out more on this object here. Using this object I can use XSL structured queries to find my device and walk through the various child nodes.  The following is a snippet of code used to get the info I need from the RIS response:

/*at this point we have already retrieved the node list and are searching for a specific IP phone*/
var nodelist = xmldom.selectNodes("//CmDevices/item[Name="" + devname.toUpperCase() + ""]");
var mytimestamp=0;
var mystatus="";
for(var row=0;row
{  //loop through nodelist
    var child = nodelist.item(row);
    var tmpstatus = child.selectSingleNode("Status").text;
    var tmptimestamp = Number(child.selectSingleNode("TimeStamp").text);
    var myipaddr = child.selectSingleNode("IpAddress").text;
    if (nodelist.length > 1 && row < nodelist.length)
    {  //we have a record with more than one result and we still have not reached the end of the results
        if (mytimestamp != 0)
        {  //we have a previous entry for this device
            if (tmptimestamp <= mytimestamp)
                { //we need to check further
                     if (tmptimestamp == mytimestamp)
                      {
                        if(mystatus == "Registered")
                        {  //if timestamps are identical and the previous child node was registered
                           // we will choose the record that is registered
                             tmpstatus = mystatus;
                             tmptimestamp = mytimestamp;
                        }
                       }else{
                              tmptimestamp = mytimestamp;
                              tmpstatus = mystatus;
                       }
                  }
            }
       }
       mystatus = tmpstatus;
       mytimestamp = tmptimestamp;
}  //end for loop; looping through nodelist
/*keep on truckin through to the next IP phone controller by an outer for loop*/

In the example, xmldom is my XML document that I have the RIS response stored from the CUCM cluster.  The program iteslf has the task of checking a list of 200 devices and determine that current status of each one.  We have an other loop (not shown) that will go through each device sequentially.  In the code shown, we are running a query against the XML data to find all nodes that match the device we care about.  We do this by searching for the “Name” attribute (e.g. Name=”SEP001EF72A48C5″).  Using the example XML we showed earlier, this would return two child nodes (one reported by the 10.10.10.7 CUCM server and the other reported by the 10.10.10.8 server).

So, we may have 1 or more child nodes to deal with.  To make sure we get the latest data (that is all we care about for the moment) we have to grab the status and timestamp information. For the first child node, we simply set the “mystatus” and “mytimestamp” variables.  On the second pass through, we actually have to check the next child node’s time stamp.  If the second time stamp is greater, we just accept that as the most valid record.  If the second time stamp is lesser, then we discard the current node’s data as it is not the most recent.

If the second time stamp is equal to the current “latest time” (mytimestamp) we check the “latest status” (mystatus) to see if we have a Registered record already.  If so, we prefer to keep that record.  This isn’t a common occurence but it can happen.

One response to “Identifying the Correct Device Status in a RISPort Response

  1. Hello,

    I’ve been reading over a lot of documents and I’ve been trying to figure out what is the best tool to use for:
    1. Locating a users phone/username/etc
    2. displaying their missed call information on a webpage
    3. having them click the link and it dials the number of the missed call on their phone.

    What I have working:
    -AXL wsdl is working and executing queries from C#.net 3.5 on AXL namespace 7.0
    -I have been able to locate user information by executing queries
    -Web Dialer is executing calls

    I really want to know if this is possible with AXL+web dialer, or if I will need to work with TAPI to get the missed call information?
    Is there just one tool I can use to get all of this done and I’ve just been over looking it in all the documentation?

    Thanks,

    -1ze

Leave a Reply

 

Nick Kelly

Cybersecurity Engineer, Cisco

Nick has over 20 years of experience in Security Operations and Security Sales. He is an avid student of cybersecurity and regularly engages with the Infosec community at events like BSides, RVASec, Derbycon and more. The son of an FBI forensics director, Nick holds a B.S. in Criminal Justice and is one of Cisco’s Fire Jumper Elite members. When he’s not working, he writes cyberpunk and punches aliens on his Playstation.

 

Virgilio “BONG” dela Cruz Jr.

CCDP, CCNA V, CCNP, Cisco IPS Express Security for AM/EE
Field Solutions Architect, Tech Data

Virgilio “Bong” has sixteen years of professional experience in IT industry from academe, technical and customer support, pre-sales, post sales, project management, training and enablement. He has worked in Cisco Technical Assistance Center (TAC) as a member of the WAN and LAN Switching team. Bong now works for Tech Data as the Field Solutions Architect with a focus on Cisco Security and holds a few Cisco certifications including Fire Jumper Elite.

 

John Cavanaugh

CCIE #1066, CCDE #20070002, CCAr
Chief Technology Officer, Practice Lead Security Services, NetCraftsmen

John is our CTO and the practice lead for a talented team of consultants focused on designing and delivering scalable and secure infrastructure solutions to customers across multiple industry verticals and technologies. Previously he has held several positions including Executive Director/Chief Architect for Global Network Services at JPMorgan Chase. In that capacity, he led a team managing network architecture and services.  Prior to his role at JPMorgan Chase, John was a Distinguished Engineer at Cisco working across a number of verticals including Higher Education, Finance, Retail, Government, and Health Care.

He is an expert in working with groups to identify business needs, and align technology strategies to enable business strategies, building in agility and scalability to allow for future changes. John is experienced in the architecture and design of highly available, secure, network infrastructure and data centers, and has worked on projects worldwide. He has worked in both the business and regulatory environments for the design and deployment of complex IT infrastructures.