NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

gov.nist.javax.sip.stack
Class DefaultRouter

java.lang.Object
  extended by gov.nist.javax.sip.stack.DefaultRouter
All Implemented Interfaces:
Router

public class DefaultRouter
extends Object
implements Router

This is the default router. When the implementation wants to forward a request and had run out of othe options, then it calls this method to figure out where to send the request. The default router implements a simple "default routing algorithm" which just forwards to the configured proxy address.

When javax.sip.USE_ROUTER_FOR_ALL_URIS is set to false, the next hop is determined according to the following algorithm:

(*)Note that in case the topmost Route header contains no 'lr' parameter (which means the next hop is a strict router), the implementation will perform 'Route Information Postprocessing' as described in RFC3261 section 16.6 step 6 (also known as "Route header popping"). That is, the following modifications will be made to the request:

  1. The implementation places the Request-URI into the Route header field as the last value.
  2. The implementation then places the first Route header field value into the Request-URI and removes that value from the Route header field.
Subsequently, the request URI will be used as next hop target

Version:
1.2 $Revision: 1.16 $ $Date: 2009/07/29 20:38:13 $
Author:
M. Ranganathan

Constructor Summary
DefaultRouter(SipStack sipStack, String defaultRoute)
          Constructor.
 
Method Summary
 void fixStrictRouting(SIPRequest req)
          Performs strict router fix according to RFC3261 section 16.6 step 6 pre: top route header in request has no 'lr' parameter in URI post: request-URI added as last route header, new req-URI = top-route-URI
 Hop getNextHop(Request request)
          Return addresses for default proxy to forward the request to.
 ListIterator getNextHops(Request request)
          Gets the ListIterator of the hops of the default Route.
 Hop getOutboundProxy()
          Get the default hop.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRouter

public DefaultRouter(SipStack sipStack,
                     String defaultRoute)
Constructor.

Method Detail

getNextHop

public Hop getNextHop(Request request)
               throws SipException
Return addresses for default proxy to forward the request to. The list is organized in the following priority. If the requestURI refers directly to a host, the host and port information are extracted from it and made the next hop on the list. If the default route has been specified, then it is used to construct the next element of the list. RouteHeader firstRoute = (RouteHeader) req.getHeader( RouteHeader.NAME ); if (firstRoute!=null) { URI uri = firstRoute.getAddress().getURI(); if (uri.isSIPUri()) { SipURI nextHop = (SipURI) uri; if ( nextHop.hasLrParam() ) { // OK, use it } else { nextHop = fixStrictRouting( req ); <--- Here, make the modifications as per RFC3261 } } else { // error: non-SIP URI not allowed in Route headers throw new SipException( "Request has Route header with non-SIP URI" ); } } else if (outboundProxy!=null) { // use outbound proxy for nextHop } else if ( req.getRequestURI().isSipURI() ) { // use request URI for nextHop }

Specified by:
getNextHop in interface Router
Parameters:
request - is the sip request to route.
Returns:
the next Hop from this Router for the Request.
Throws:
SipException - when there is something wrong with the request
See Also:
Hop

fixStrictRouting

public void fixStrictRouting(SIPRequest req)
Performs strict router fix according to RFC3261 section 16.6 step 6 pre: top route header in request has no 'lr' parameter in URI post: request-URI added as last route header, new req-URI = top-route-URI


getOutboundProxy

public Hop getOutboundProxy()
Get the default hop.

Specified by:
getOutboundProxy in interface Router
Returns:
defaultRoute is the default route. public java.util.Iterator getDefaultRoute(Request request) { return this.getNextHops((SIPRequest)request); }
See Also:
Hop

getNextHops

public ListIterator getNextHops(Request request)
Description copied from interface: Router
Gets the ListIterator of the hops of the default Route. This method may return null if a default route is not defined.

Specified by:
getNextHops in interface Router

NIST-SIP: The Reference Implementation for JAIN-SIP 1.2

A product of the NIST/ITL Advanced Networking Technologies Division.
See conditions of use.
Submit a bug report or feature request.