Child pages
  • Diameter

This documentation relates to last stable version of Cipango.
visit the last unstable documentation home.

Skip to end of metadata
Go to start of metadata


Diameter support in Cipango is designed to offer a servlet-like programming model.


Adding diameter support

Diameter support is optional and should be activated first. To start Cipango with diameter, add the diameter.xml to the command runline. For instance:

java -jar start.jar --ini=start-cipango.ini etc/diameter.xml


Diameter messages are logged in the file ${jetty.home}/logs/yyyy_mm_dd.diameter.log (replace yyyy_mm_dd by the current date).



Javadoc is available at


To use diameter, a class implementing the DiameterListener must be declared within the application. This is similar to the TimerListener used for the SIP Servlet TimerService.This interface is then invoked when diameter messages are received.

The DiameterListener is defined as follows:

package org.cipango.diameter.api;

public interface DiameterListener extends EventListener
	 * The <code>handle</code> method is invoked by the container when a Diameter message should be
	 * passed to the application.
	void handle(DiameterServletMessage message) throws IOException;

The DiameterFactory

The DiameterFactory class is used to create instances of DiameterServletRequest.

Cipango makes an instance of org.cipango.diameter.api.DiameterFactory available to servlets via the servlet context attribute of the same name, org.cipango.diameter.api.DiameterFactory.


Send request

The following code sample illustrates how to create an UDR request:

protected void doRequest(SipServletRequest sipRequest) throws ServletException, IOException
    DiameterFactory factory = (DiameterFactory) getServletContext().getAttribute(DiameterFactory.class.getName());
    DiameterServletRequest request = factory.createRequest(sipRequest.getApplicationSession(),Sh.SH_APPLICATION_ID, Sh.UDR,"","");
    AVPList userIdentity = new AVPList();
    userIdentity.add(Cx.PUBLIC_IDENTITY, "");
    request.add(Sh.USER_IDENTITY, userIdentity);
    request.add(Sh.DATA_REFERENCE, Sh.DataReference.IMSUserState);
    request.setAttribute("request", sipRequest);

Handling answer

When the UDA answer is received, the handle method of the DiameterListener interface is invoked and the requested data could be retrieved as follows:

public void handle(DiameterServletMessage message) throws IOException
    if (!message.isRequest())
      DiameterServletAnswer answer = (DiameterServletAnswer) message;
      byte[] data = answer.get(Sh.USER_DATA);
      // process sh data

      SipServletRequest request = (SipServletRequest) answer.getRequest().getAttribute("request");
      SipServletResponse response = request.createResponse(200);
      // Error processing
  catch (Throwable e)
    // Error processing
  • No labels