net.floodlightcontroller.packet
Class Ethernet

java.lang.Object
  extended by net.floodlightcontroller.packet.BasePacket
      extended by net.floodlightcontroller.packet.Ethernet
All Implemented Interfaces:
IPacket

public class Ethernet
extends BasePacket

Author:
David Erickson (daviderickson@cs.stanford.edu)

Field Summary
static short DATALAYER_ADDRESS_LENGTH
           
protected  MACAddress destinationMACAddress
           
protected  short etherType
           
static java.util.Map<java.lang.Short,java.lang.Class<? extends IPacket>> etherTypeClassMap
           
protected  boolean pad
           
protected  byte priorityCode
           
protected  MACAddress sourceMACAddress
           
static short TYPE_ARP
           
static short TYPE_BSN
           
static short TYPE_IPv4
           
static short TYPE_LLDP
           
static short TYPE_RARP
           
static short VLAN_UNTAGGED
           
protected  short vlanID
           
 
Fields inherited from class net.floodlightcontroller.packet.BasePacket
log, parent, payload
 
Constructor Summary
Ethernet()
          By default, set Ethernet to untagged
 
Method Summary
 IPacket deserialize(byte[] data, int offset, int length)
          Deserializes this packet layer and all possible payloads
 boolean equals(java.lang.Object obj)
           
 MACAddress getDestinationMAC()
           
 byte[] getDestinationMACAddress()
           
 short getEtherType()
           
 byte getPriorityCode()
           
 MACAddress getSourceMAC()
           
 byte[] getSourceMACAddress()
           
 short getVlanID()
           
 int hashCode()
           
 boolean isBroadcast()
           
static boolean isMACAddress(java.lang.String macAddress)
          Checks to see if a string is a valid MAC address.
 boolean isMulticast()
           
 boolean isPad()
          Pad this packet to 60 bytes minimum, filling with zeros?
 byte[] serialize()
          Sets all payloads parent packet if applicable, then serializes this packet and all payloads
 Ethernet setDestinationMACAddress(byte[] destinationMACAddress)
           
 Ethernet setDestinationMACAddress(java.lang.String destinationMACAddress)
           
 Ethernet setEtherType(short etherType)
           
 Ethernet setPad(boolean pad)
          Pad this packet to 60 bytes minimum, filling with zeros?
 Ethernet setPriorityCode(byte priorityCode)
           
 Ethernet setSourceMACAddress(byte[] sourceMACAddress)
           
 Ethernet setSourceMACAddress(java.lang.String sourceMACAddress)
           
 Ethernet setVlanID(short vlanID)
           
static byte[] toByteArray(long macAddress)
          Convert a long MAC address to a byte array
static long toLong(byte[] macAddress)
          Accepts a MAC address and returns the corresponding long, where the MAC bytes are set on the lower order bytes of the long.
static byte[] toMACAddress(java.lang.String macAddress)
          Accepts a MAC address of the form 00:aa:11:bb:22:cc, case does not matter, and returns a corresponding byte[].
 java.lang.String toString()
           
 
Methods inherited from class net.floodlightcontroller.packet.BasePacket
clone, getParent, getPayload, resetChecksum, setParent, setPayload
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_ARP

public static final short TYPE_ARP
See Also:
Constant Field Values

TYPE_RARP

public static final short TYPE_RARP
See Also:
Constant Field Values

TYPE_IPv4

public static final short TYPE_IPv4
See Also:
Constant Field Values

TYPE_LLDP

public static final short TYPE_LLDP
See Also:
Constant Field Values

TYPE_BSN

public static final short TYPE_BSN
See Also:
Constant Field Values

VLAN_UNTAGGED

public static final short VLAN_UNTAGGED
See Also:
Constant Field Values

DATALAYER_ADDRESS_LENGTH

public static final short DATALAYER_ADDRESS_LENGTH
See Also:
Constant Field Values

etherTypeClassMap

public static java.util.Map<java.lang.Short,java.lang.Class<? extends IPacket>> etherTypeClassMap

destinationMACAddress

protected MACAddress destinationMACAddress

sourceMACAddress

protected MACAddress sourceMACAddress

priorityCode

protected byte priorityCode

vlanID

protected short vlanID

etherType

protected short etherType

pad

protected boolean pad
Constructor Detail

Ethernet

public Ethernet()
By default, set Ethernet to untagged

Method Detail

getDestinationMACAddress

public byte[] getDestinationMACAddress()
Returns:
the destination MAC as a byte array

getDestinationMAC

public MACAddress getDestinationMAC()
Returns:
the destination MAC

setDestinationMACAddress

public Ethernet setDestinationMACAddress(byte[] destinationMACAddress)
Parameters:
destinationMACAddress - the destination MAC to set

setDestinationMACAddress

public Ethernet setDestinationMACAddress(java.lang.String destinationMACAddress)
Parameters:
destinationMACAddress - the destination MAC to set

getSourceMACAddress

public byte[] getSourceMACAddress()
Returns:
the source MACAddress as a byte array

getSourceMAC

public MACAddress getSourceMAC()
Returns:
the source MACAddress

setSourceMACAddress

public Ethernet setSourceMACAddress(byte[] sourceMACAddress)
Parameters:
sourceMACAddress - the source MAC to set

setSourceMACAddress

public Ethernet setSourceMACAddress(java.lang.String sourceMACAddress)
Parameters:
sourceMACAddress - the source MAC to set

getPriorityCode

public byte getPriorityCode()
Returns:
the priorityCode

setPriorityCode

public Ethernet setPriorityCode(byte priorityCode)
Parameters:
priorityCode - the priorityCode to set

getVlanID

public short getVlanID()
Returns:
the vlanID

setVlanID

public Ethernet setVlanID(short vlanID)
Parameters:
vlanID - the vlanID to set

getEtherType

public short getEtherType()
Returns:
the etherType

setEtherType

public Ethernet setEtherType(short etherType)
Parameters:
etherType - the etherType to set

isBroadcast

public boolean isBroadcast()
Returns:
True if the Ethernet frame is broadcast, false otherwise

isMulticast

public boolean isMulticast()
Returns:
True is the Ethernet frame is multicast, False otherwise

isPad

public boolean isPad()
Pad this packet to 60 bytes minimum, filling with zeros?

Returns:
the pad

setPad

public Ethernet setPad(boolean pad)
Pad this packet to 60 bytes minimum, filling with zeros?

Parameters:
pad - the pad to set

serialize

public byte[] serialize()
Description copied from interface: IPacket
Sets all payloads parent packet if applicable, then serializes this packet and all payloads

Returns:
a byte[] containing this packet and payloads

deserialize

public IPacket deserialize(byte[] data,
                           int offset,
                           int length)
Description copied from interface: IPacket
Deserializes this packet layer and all possible payloads

offset - offset to start deserializing from
length - length of the data to deserialize
Returns:
the deserialized data

isMACAddress

public static boolean isMACAddress(java.lang.String macAddress)
Checks to see if a string is a valid MAC address.

Parameters:
macAddress -
Returns:
True if macAddress is a valid MAC, False otherwise

toMACAddress

public static byte[] toMACAddress(java.lang.String macAddress)
Accepts a MAC address of the form 00:aa:11:bb:22:cc, case does not matter, and returns a corresponding byte[].

Parameters:
macAddress - The MAC address to convert into a bye array
Returns:
The macAddress as a byte array

toLong

public static long toLong(byte[] macAddress)
Accepts a MAC address and returns the corresponding long, where the MAC bytes are set on the lower order bytes of the long.

Parameters:
macAddress -
Returns:
a long containing the mac address bytes

toByteArray

public static byte[] toByteArray(long macAddress)
Convert a long MAC address to a byte array

Parameters:
macAddress -
Returns:
the bytes of the mac address

hashCode

public int hashCode()
Overrides:
hashCode in class BasePacket

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class BasePacket

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object