jist.swans.route
Class RouteDsrMsg.OptionSourceRoute

java.lang.Object
  extended by jist.swans.route.RouteDsrMsg.Option
      extended by jist.swans.route.RouteDsrMsg.OptionSourceRoute
Enclosing class:
RouteDsrMsg

public static class RouteDsrMsg.OptionSourceRoute
extends RouteDsrMsg.Option

A Source Route option.


Field Summary
 
Fields inherited from class jist.swans.route.RouteDsrMsg.Option
optBuf, optBufOffset
 
Constructor Summary
RouteDsrMsg.OptionSourceRoute(byte[] buf, int offset)
          
 
Method Summary
static byte[] create(boolean firstHopExternal, boolean lastHopExternal, int salvage, int segsLeft, NetAddress[] addrs)
          Creates a new Source Route option.
static byte[] create(int salvage, int segsLeft, NetAddress[] addrs)
          Creates a new Source Route option with the First Hop External and the Last Hop External fields set to false.
 NetAddress getAddress(int n)
          Returns the nth address on the route, counting the first hop after the source as node zero.
 int getNumAddresses()
          Returns the number of addresses in the route, not including the source and destination addresses.
 int getNumSegmentsLeft()
          Returns the number of segments on the source route that have yet to be traversed.
 int getSalvageCount()
          Returns the salvage count of this option.
 int getSize()
          Returns the size in bytes of this option.
 byte getType()
          Returns the DSR type code for this kind of option.
 boolean isFirstHopExternal()
          Indicates whether the first hop on the route is external to the DSR network.
 boolean isLastHopExternal()
          Indicates whether the last hop on the route is external to the DSR network.
 
Methods inherited from class jist.swans.route.RouteDsrMsg.Option
create, equals, getBytes, getType, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RouteDsrMsg.OptionSourceRoute

public RouteDsrMsg.OptionSourceRoute(byte[] buf,
                                     int offset)

Method Detail

getType

public byte getType()
Returns the DSR type code for this kind of option.

Specified by:
getType in class RouteDsrMsg.Option
Returns:
the DSR type code for this kind of option.

getSize

public int getSize()
Returns the size in bytes of this option.

Specified by:
getSize in class RouteDsrMsg.Option
Returns:
the size in bytes of this option.

isFirstHopExternal

public boolean isFirstHopExternal()
Indicates whether the first hop on the route is external to the DSR network.

Returns:
whether the first hop is external.

isLastHopExternal

public boolean isLastHopExternal()
Indicates whether the last hop on the route is external to the DSR network.

Returns:
whether the last hop is external.

getSalvageCount

public int getSalvageCount()
Returns the salvage count of this option.

Returns:
the salvage count of this option.

getNumSegmentsLeft

public int getNumSegmentsLeft()
Returns the number of segments on the source route that have yet to be traversed.

Returns:
the number of segments on the route left to go.

getNumAddresses

public int getNumAddresses()
Returns the number of addresses in the route, not including the source and destination addresses.

Returns:
the number of addresses in the route.

getAddress

public NetAddress getAddress(int n)
Returns the nth address on the route, counting the first hop after the source as node zero.

Parameters:
n - the index into the route
Returns:
the address in the route indexed by n.

create

public static byte[] create(boolean firstHopExternal,
                            boolean lastHopExternal,
                            int salvage,
                            int segsLeft,
                            NetAddress[] addrs)
Creates a new Source Route option.

Parameters:
firstHopExternal - whether the first hop on the route is external
lastHopExternal - whether the last hop on the route is external
salvage - the salvage count
segsLeft - the number of explicitly listed intermediate nodes still to be visited before reaching the final destination
addrs - the addresses of the nodes along the route
Returns:
The byte array corresponding to the desired option.

create

public static byte[] create(int salvage,
                            int segsLeft,
                            NetAddress[] addrs)
Creates a new Source Route option with the First Hop External and the Last Hop External fields set to false.

Parameters:
salvage - the salvage count
segsLeft - the number of explicitly listed intermediate nodes still to be visited before reaching the final destination
addrs - the addresses of the nodes along the route
Returns:
the byte array corresponding to the desired option.