net.clackrouter.packets
Class VNSEthernetPacket

java.lang.Object
  extended by net.clackrouter.protocol.data.VNSData
      extended by net.clackrouter.packets.VNSPacket
          extended by net.clackrouter.packets.VNSEthernetPacket

public final class VNSEthernetPacket
extends VNSPacket

Encapsulates an Ethernet frame.


Field Summary
static int ADDR_LEN
          Length of source and destination address fields.
static int BODY_LEN
          Length of the body.
static int MAX_LEN
          Total maximum length of an Ethernet frame.
static short TYPE_ARP
          Value of the type field if higher-level protocol is ARP.
static short TYPE_IP
          Value of the type field if higher-level protocol is IP.
static int TYPE_LEN
          Length of the type field.
 
Fields inherited from class net.clackrouter.packets.VNSPacket
m_inputInterfaceName, m_length, m_level2Type, m_local_packet, m_nextHopIPAddr, m_nextHopMacAddr, m_outputInterfaceName, m_packetByteBuffer, mParentHeader
 
Constructor Summary
VNSEthernetPacket(java.nio.ByteBuffer packetByteBuffer)
          Constructs an Ethernet frame from the supplied byte buffer.
 
Method Summary
 java.nio.ByteBuffer getBodyBuffer()
          Returns the body of the Ethernet frame.
static java.nio.ByteBuffer getBroadcastAddress()
           
 java.nio.ByteBuffer getDestinationAddressBuffer()
          Returns destination hardware address.
 VNSPacket getPayload()
           
 java.nio.ByteBuffer getSourceAddressBuffer()
          Returns source hardware address.
 short getType()
          Returns type of the higher-level protocol.
 java.nio.ByteBuffer getTypeBuffer()
          Returns type of the higher-level protocol.
 void pack()
           
 void setBodyBuffer(java.nio.ByteBuffer body)
          Sets the body of the Ethernet frame to the supplied byte buffer.
 void setDestinationAddressBuffer(java.nio.ByteBuffer dstAddr)
          Sets the destination hardware address of the Ethernet frame to the supplied byte buffer.
 void setSourceAddressBuffer(java.nio.ByteBuffer srcAddr)
          Sets the source hardware address of the Ethernet frame to the supplied byte buffer.
 java.lang.String toString()
          Presents an Ethernet frame in a readable format, by field.
static VNSEthernetPacket wrap(VNSPacket packet, java.nio.ByteBuffer dstAddr, java.nio.ByteBuffer srcAddr, java.nio.ByteBuffer type)
          Constructs an Ethernet packet from its individual fields.
 
Methods inherited from class net.clackrouter.packets.VNSPacket
addToPath, get16bit, get32bit, getByteBuffer, getInputInterfaceName, getLength, getLevel2Type, getNextHopIPAddress, getNextHopMacAddress, getOutputInterfaceName, getParentHeader, getStringBuffer, isPacket, needsSourceAddress, setByteBuffer, setInputInterfaceName, setLevel2Type, setNeedsSourceAddress, setNextHopIPAddress, setNextHopMacAddress, setOutputInterfaceName, setParentHeader
 
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

ADDR_LEN

public static final int ADDR_LEN
Length of source and destination address fields.

See Also:
Constant Field Values

TYPE_LEN

public static final int TYPE_LEN
Length of the type field.

See Also:
Constant Field Values

BODY_LEN

public static final int BODY_LEN
Length of the body.

See Also:
Constant Field Values

MAX_LEN

public static final int MAX_LEN
Total maximum length of an Ethernet frame.

See Also:
Constant Field Values

TYPE_IP

public static final short TYPE_IP
Value of the type field if higher-level protocol is IP.

See Also:
Constant Field Values

TYPE_ARP

public static final short TYPE_ARP
Value of the type field if higher-level protocol is ARP.

See Also:
Constant Field Values
Constructor Detail

VNSEthernetPacket

public VNSEthernetPacket(java.nio.ByteBuffer packetByteBuffer)
Constructs an Ethernet frame from the supplied byte buffer.

Parameters:
packetByteBuffer - Buffer of bytes representing an Ethernet frame
Method Detail

pack

public void pack()

getDestinationAddressBuffer

public java.nio.ByteBuffer getDestinationAddressBuffer()
Returns destination hardware address.

Returns:
Byte buffer containing the destination hardware address

getSourceAddressBuffer

public java.nio.ByteBuffer getSourceAddressBuffer()
Returns source hardware address.

Returns:
Byte buffer containing the source hardware address

getTypeBuffer

public java.nio.ByteBuffer getTypeBuffer()
Returns type of the higher-level protocol.

Returns:
Byte buffer containing the type of the higher-level protocol
See Also:
getType()

getBodyBuffer

public java.nio.ByteBuffer getBodyBuffer()
Returns the body of the Ethernet frame.

Returns:
Byte buffer containing the body of the Ethernet frame

getType

public short getType()
Returns type of the higher-level protocol.

Returns:
Type of the higher-level protocol
See Also:
getTypeBuffer()

setBodyBuffer

public void setBodyBuffer(java.nio.ByteBuffer body)
Sets the body of the Ethernet frame to the supplied byte buffer.

Parameters:
body - Byte buffer containing the body of the Ethernet frame
See Also:
getBodyBuffer()

setSourceAddressBuffer

public void setSourceAddressBuffer(java.nio.ByteBuffer srcAddr)
Sets the source hardware address of the Ethernet frame to the supplied byte buffer.

Parameters:
srcAddr - Byte buffer containing the source hardware address of the Ethernet frame

setDestinationAddressBuffer

public void setDestinationAddressBuffer(java.nio.ByteBuffer dstAddr)
Sets the destination hardware address of the Ethernet frame to the supplied byte buffer.

Parameters:
dstAddr - Byte buffer containing the destination hardware address of the Ethernet frame

wrap

public static VNSEthernetPacket wrap(VNSPacket packet,
                                     java.nio.ByteBuffer dstAddr,
                                     java.nio.ByteBuffer srcAddr,
                                     java.nio.ByteBuffer type)
                              throws VNSInvalidPacketException
Constructs an Ethernet packet from its individual fields.

Parameters:
packet - Any packet except an Ethernet frame
dstAddr - Destination hardware address
srcAddr - Source hardware address
type - Type of the higher-level protocol *
Throws:
VNSInvalidPacketException

toString

public java.lang.String toString()
Presents an Ethernet frame in a readable format, by field.

Overrides:
toString in class VNSPacket
Returns:
The fields of the Ethernet frame

getBroadcastAddress

public static java.nio.ByteBuffer getBroadcastAddress()

getPayload

public VNSPacket getPayload()