net.clackrouter.packets
Class VNSPacket

java.lang.Object
  extended by net.clackrouter.protocol.data.VNSData
      extended by net.clackrouter.packets.VNSPacket
Direct Known Subclasses:
DNSPacket, IPPacket, LinkStatePacket, RIPRoutingUpdate, SSHPacket, VNSARPPacket, VNSEthernetPacket, VNSICMPPacket, VNSTCPPacket, VNSUDPPacket

public class VNSPacket
extends VNSData

Encapsulates common functionality of a packet.


Field Summary
protected  java.lang.String m_inputInterfaceName
           
protected  int m_length
           
protected  java.nio.ByteBuffer m_level2Type
           
protected  boolean m_local_packet
           
protected  java.nio.ByteBuffer m_nextHopIPAddr
           
protected  java.nio.ByteBuffer m_nextHopMacAddr
           
protected  java.lang.String m_outputInterfaceName
           
protected  java.nio.ByteBuffer m_packetByteBuffer
           
protected  VNSPacket mParentHeader
           
 
Constructor Summary
protected VNSPacket()
          Constructs a packet of zero length.
  VNSPacket(java.nio.ByteBuffer packetByteBuffer)
          Constructs a packet from the supplied byte buffer.
 
Method Summary
 void addToPath(java.lang.String name)
           
static int get16bit(byte[] arr)
           
static long get32bit(byte[] arr)
           
 java.nio.ByteBuffer getByteBuffer()
          Returns the byte buffer containing the packet's bytes.
 java.lang.String getInputInterfaceName()
          Returns the interface name on which the packet came in, e.g.
 int getLength()
          Returns the length of the packet, in bytes.
 java.nio.ByteBuffer getLevel2Type()
           
 java.nio.ByteBuffer getNextHopIPAddress()
          Returns the packet's next-hop IP address.
 java.nio.ByteBuffer getNextHopMacAddress()
           
 java.lang.String getOutputInterfaceName()
          Returns the interfaces name on which the packet will leave, e.g "eth1".
 VNSPacket getParentHeader()
           
protected  java.lang.StringBuffer getStringBuffer(java.nio.ByteBuffer byteBuffer)
           
 boolean isPacket()
           
 boolean needsSourceAddress()
           
protected  void setByteBuffer(java.nio.ByteBuffer packetByteBuffer)
          Sets the packet's byte buffer to the supplied byte buffer.
 void setInputInterfaceName(java.lang.String inputInterfaceName)
          Sets the input interface on which the packet came in.
 void setLevel2Type(java.nio.ByteBuffer type)
           
 void setNeedsSourceAddress(boolean local)
           
 void setNextHopIPAddress(java.nio.ByteBuffer nextHopAddr)
          Sets packet's next-hop IP address.
 void setNextHopMacAddress(java.nio.ByteBuffer nextHopMacAddr)
           
 void setOutputInterfaceName(java.lang.String outputInterfaceName)
          Sets the output interface on which the packet will go out.
 void setParentHeader(VNSPacket parent)
           
 java.lang.String toString()
          Represents the packet in a readable format, by field.
 
Methods inherited from class net.clackrouter.protocol.data.VNSData
isBanner, isClose, isHWInfo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_inputInterfaceName

protected java.lang.String m_inputInterfaceName

m_outputInterfaceName

protected java.lang.String m_outputInterfaceName

m_nextHopIPAddr

protected java.nio.ByteBuffer m_nextHopIPAddr

m_nextHopMacAddr

protected java.nio.ByteBuffer m_nextHopMacAddr

m_level2Type

protected java.nio.ByteBuffer m_level2Type

m_local_packet

protected boolean m_local_packet

m_packetByteBuffer

protected java.nio.ByteBuffer m_packetByteBuffer

m_length

protected int m_length

mParentHeader

protected VNSPacket mParentHeader
Constructor Detail

VNSPacket

public VNSPacket(java.nio.ByteBuffer packetByteBuffer)
Constructs a packet from the supplied byte buffer. The buffer is presumed to contain the full contents of the packet.

Parameters:
packetByteBuffer - Byte buffer containing bytes representing the packet

VNSPacket

protected VNSPacket()
Constructs a packet of zero length.

Method Detail

isPacket

public boolean isPacket()
Overrides:
isPacket in class VNSData

getStringBuffer

protected java.lang.StringBuffer getStringBuffer(java.nio.ByteBuffer byteBuffer)

setByteBuffer

protected void setByteBuffer(java.nio.ByteBuffer packetByteBuffer)
Sets the packet's byte buffer to the supplied byte buffer.

Parameters:
packetByteBuffer - Byte buffer containing bytes representing the packet

setParentHeader

public void setParentHeader(VNSPacket parent)

getParentHeader

public VNSPacket getParentHeader()

getInputInterfaceName

public java.lang.String getInputInterfaceName()
Returns the interface name on which the packet came in, e.g. "eth0".

Returns:
Interface name on which the packet came in

getOutputInterfaceName

public java.lang.String getOutputInterfaceName()
Returns the interfaces name on which the packet will leave, e.g "eth1".

Returns:
Interfaces name on which the packet will leave

getNextHopIPAddress

public java.nio.ByteBuffer getNextHopIPAddress()
Returns the packet's next-hop IP address. This parameter is set at the time of address lookup.

Returns:
Byte buffer containing packet's next-hop IP address

setNeedsSourceAddress

public void setNeedsSourceAddress(boolean local)

needsSourceAddress

public boolean needsSourceAddress()

setInputInterfaceName

public void setInputInterfaceName(java.lang.String inputInterfaceName)
Sets the input interface on which the packet came in.

Parameters:
inputInterfaceName - Interface on which the packet came in

setOutputInterfaceName

public void setOutputInterfaceName(java.lang.String outputInterfaceName)
Sets the output interface on which the packet will go out.

Parameters:
outputInterfaceName - Interface on which the packet will go out

setNextHopIPAddress

public void setNextHopIPAddress(java.nio.ByteBuffer nextHopAddr)
Sets packet's next-hop IP address. This operaion is performed at the time of address lookup but can be done at any time by any mischievous box.

Parameters:
nextHopAddr - Next-hop IP address.

setNextHopMacAddress

public void setNextHopMacAddress(java.nio.ByteBuffer nextHopMacAddr)

getNextHopMacAddress

public java.nio.ByteBuffer getNextHopMacAddress()

setLevel2Type

public void setLevel2Type(java.nio.ByteBuffer type)

getLevel2Type

public java.nio.ByteBuffer getLevel2Type()

getByteBuffer

public java.nio.ByteBuffer getByteBuffer()
Returns the byte buffer containing the packet's bytes.

Returns:
Byte buffer containing the packet's bytes

getLength

public int getLength()
Returns the length of the packet, in bytes.

Returns:
Number of bytes in the packet

toString

public java.lang.String toString()
Represents the packet in a readable format, by field.

Overrides:
toString in class java.lang.Object
Returns:
Packet in readable format

addToPath

public void addToPath(java.lang.String name)

get32bit

public static long get32bit(byte[] arr)

get16bit

public static int get16bit(byte[] arr)