jist.swans.route
Class RouteDsrMsg.Option

java.lang.Object
  extended by jist.swans.route.RouteDsrMsg.Option
Direct Known Subclasses:
RouteDsrMsg.OptionAck, RouteDsrMsg.OptionAckRequest, RouteDsrMsg.OptionPad1, RouteDsrMsg.OptionPadN, RouteDsrMsg.OptionRouteError, RouteDsrMsg.OptionRouteReply, RouteDsrMsg.OptionRouteRequest, RouteDsrMsg.OptionSourceRoute
Enclosing class:
RouteDsrMsg

public abstract static class RouteDsrMsg.Option
extends java.lang.Object

The base class for all DSR header options.


Field Summary
protected  byte[] optBuf
          The raw bytes of the option.
protected  int optBufOffset
          The offset into optbuf where the option encoding begins.
 
Constructor Summary
RouteDsrMsg.Option(byte[] buf, int offset)
          Creates a new option from the given byte array, starting at the given offset.
 
Method Summary
static RouteDsrMsg.Option create(byte[] buf, int offset)
          Creates a new Option from the given byte array, starting at the given offset.
 boolean equals(java.lang.Object o)
          
 int getBytes(byte[] buf, int offset)
          Retrieves the actual bytes of the option.
abstract  int getSize()
          Returns the size in bytes of this option.
abstract  byte getType()
          Returns the DSR type code for this kind of option.
static byte getType(byte[] buf)
          Returns the DSR type code for the given option.
 int hashCode()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

optBuf

protected byte[] optBuf
The raw bytes of the option.


optBufOffset

protected int optBufOffset
The offset into optbuf where the option encoding begins.

Constructor Detail

RouteDsrMsg.Option

public RouteDsrMsg.Option(byte[] buf,
                          int offset)
Creates a new option from the given byte array, starting at the given offset.

Parameters:
buf - the buffer containing the option
offset - the offset into buf where the option begins
Method Detail

getType

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

Returns:
the DSR type code for this kind of option.

getSize

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

Returns:
the size in bytes of this option.

getType

public static byte getType(byte[] buf)
Returns the DSR type code for the given option.

Parameters:
buf - a DSR option in raw byte form
Returns:
the DSR type code of buf.

getBytes

public int getBytes(byte[] buf,
                    int offset)
Retrieves the actual bytes of the option. Copies up to the end of the buffer or the end of the option, whichever comes first.

Parameters:
buf - the buffer to put the option bytes in
offset - the offset into the buffer to start writing at
Returns:
the number of bytes written.

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

create

public static RouteDsrMsg.Option create(byte[] buf,
                                        int offset)
Creates a new Option from the given byte array, starting at the given offset.

Parameters:
buf - the DSR option in raw byte form
offset - the offset into buf where the option begins
Returns:
the DSR option encoded in buf, or null if buf is not a recognized option.