public class DefaultRouter extends Object implements Router
When javax.sip.USE_ROUTER_FOR_ALL_URIS
is set to
false
, the next hop is determined according to the following
algorithm:
javax.sip.OUTBOUND_PROXY
is set,
use its value as the next hop
Router.getNextHop(Request)
provided
by the application.
(*)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:
Constructor and Description |
---|
DefaultRouter(SipStack sipStack,
String defaultRoute)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Hop |
createHop(SipURI sipUri,
Request request)
Utility method to create a hop from a SIP URI
|
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.
|
public Hop getNextHop(Request request) throws SipException
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
}
getNextHop
in interface Router
request
- is the sip request to route.SipException
- when there is something wrong with the requestHop
public void fixStrictRouting(SIPRequest req)
protected final Hop createHop(SipURI sipUri, Request request)
sipUri
- public Hop getOutboundProxy()
getOutboundProxy
in interface Router
Hop
public ListIterator getNextHops(Request request)
Router
getNextHops
in interface Router
Copyright © 2015. All Rights Reserved.