net.floodlightcontroller.packet
Class DHCP

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

public class DHCP
extends BasePacket

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

Nested Class Summary
static class DHCP.DHCPOptionCode
           
 
Field Summary
protected  java.lang.String bootFileName
           
protected  byte[] clientHardwareAddress
           
protected  int clientIPAddress
           
protected  short flags
           
protected  int gatewayIPAddress
           
protected  byte hardwareAddressLength
           
protected  byte hardwareType
           
protected  byte hops
           
static byte HWTYPE_ETHERNET
           
static int MIN_HEADER_LENGTH
          ------------------------------------------ |op (1) | htype(1) | hlen(1) | hops(1) | ------------------------------------------ | xid (4) | ------------------------------------------ | secs (2) | flags (2) | ------------------------------------------ | ciaddr (4) | ------------------------------------------ | yiaddr (4) | ------------------------------------------ | siaddr (4) | ------------------------------------------ | giaddr (4) | ------------------------------------------ | chaddr (16) | ------------------------------------------ | sname (64) | ------------------------------------------ | file (128) | ------------------------------------------ | options (312) | ------------------------------------------
protected  byte opCode
           
static byte OPCODE_REPLY
           
static byte OPCODE_REQUEST
           
protected  java.util.List<DHCPOption> options
           
protected  short seconds
           
protected  int serverIPAddress
           
protected  java.lang.String serverName
           
protected  int transactionId
           
protected  int yourIPAddress
           
 
Fields inherited from class net.floodlightcontroller.packet.BasePacket
log, parent, payload
 
Constructor Summary
DHCP()
           
 
Method Summary
 IPacket deserialize(byte[] data, int offset, int length)
          Deserializes this packet layer and all possible payloads
 java.lang.String getBootFileName()
           
 byte[] getClientHardwareAddress()
           
 int getClientIPAddress()
           
 short getFlags()
           
 int getGatewayIPAddress()
           
 byte getHardwareAddressLength()
           
 byte getHardwareType()
           
 byte getHops()
           
 byte getOpCode()
           
 DHCPOption getOption(DHCP.DHCPOptionCode optionCode)
          Gets a specific DHCP option parameter
 java.util.List<DHCPOption> getOptions()
           
 DHCPPacketType getPacketType()
           
 short getSeconds()
           
 int getServerIPAddress()
           
 java.lang.String getServerName()
           
 int getTransactionId()
           
 int getYourIPAddress()
           
protected  java.lang.String readString(java.nio.ByteBuffer bb, int maxLength)
           
 byte[] serialize()
          Sets all payloads parent packet if applicable, then serializes this packet and all payloads
 DHCP setBootFileName(java.lang.String bootFileName)
           
 DHCP setClientHardwareAddress(byte[] clientHardwareAddress)
           
 DHCP setClientIPAddress(int clientIPAddress)
           
 DHCP setFlags(short flags)
           
 DHCP setGatewayIPAddress(int gatewayIPAddress)
           
 DHCP setHardwareAddressLength(byte hardwareAddressLength)
           
 DHCP setHardwareType(byte hardwareType)
           
 DHCP setHops(byte hops)
           
 DHCP setOpCode(byte opCode)
           
 DHCP setOptions(java.util.List<DHCPOption> options)
           
 DHCP setSeconds(short seconds)
           
 DHCP setServerIPAddress(int serverIPAddress)
           
 DHCP setServerName(java.lang.String serverName)
           
 DHCP setTransactionId(int transactionId)
           
 DHCP setYourIPAddress(int yourIPAddress)
           
protected  void writeString(java.lang.String string, java.nio.ByteBuffer bb, int maxLength)
           
 
Methods inherited from class net.floodlightcontroller.packet.BasePacket
clone, equals, getParent, getPayload, hashCode, resetChecksum, setParent, setPayload
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_HEADER_LENGTH

public static int MIN_HEADER_LENGTH
------------------------------------------ |op (1) | htype(1) | hlen(1) | hops(1) | ------------------------------------------ | xid (4) | ------------------------------------------ | secs (2) | flags (2) | ------------------------------------------ | ciaddr (4) | ------------------------------------------ | yiaddr (4) | ------------------------------------------ | siaddr (4) | ------------------------------------------ | giaddr (4) | ------------------------------------------ | chaddr (16) | ------------------------------------------ | sname (64) | ------------------------------------------ | file (128) | ------------------------------------------ | options (312) | ------------------------------------------


OPCODE_REQUEST

public static byte OPCODE_REQUEST

OPCODE_REPLY

public static byte OPCODE_REPLY

HWTYPE_ETHERNET

public static byte HWTYPE_ETHERNET

opCode

protected byte opCode

hardwareType

protected byte hardwareType

hardwareAddressLength

protected byte hardwareAddressLength

hops

protected byte hops

transactionId

protected int transactionId

seconds

protected short seconds

flags

protected short flags

clientIPAddress

protected int clientIPAddress

yourIPAddress

protected int yourIPAddress

serverIPAddress

protected int serverIPAddress

gatewayIPAddress

protected int gatewayIPAddress

clientHardwareAddress

protected byte[] clientHardwareAddress

serverName

protected java.lang.String serverName

bootFileName

protected java.lang.String bootFileName

options

protected java.util.List<DHCPOption> options
Constructor Detail

DHCP

public DHCP()
Method Detail

getOpCode

public byte getOpCode()
Returns:
the opCode

setOpCode

public DHCP setOpCode(byte opCode)
Parameters:
opCode - the opCode to set

getHardwareType

public byte getHardwareType()
Returns:
the hardwareType

setHardwareType

public DHCP setHardwareType(byte hardwareType)
Parameters:
hardwareType - the hardwareType to set

getHardwareAddressLength

public byte getHardwareAddressLength()
Returns:
the hardwareAddressLength

setHardwareAddressLength

public DHCP setHardwareAddressLength(byte hardwareAddressLength)
Parameters:
hardwareAddressLength - the hardwareAddressLength to set

getHops

public byte getHops()
Returns:
the hops

setHops

public DHCP setHops(byte hops)
Parameters:
hops - the hops to set

getTransactionId

public int getTransactionId()
Returns:
the transactionId

setTransactionId

public DHCP setTransactionId(int transactionId)
Parameters:
transactionId - the transactionId to set

getSeconds

public short getSeconds()
Returns:
the seconds

setSeconds

public DHCP setSeconds(short seconds)
Parameters:
seconds - the seconds to set

getFlags

public short getFlags()
Returns:
the flags

setFlags

public DHCP setFlags(short flags)
Parameters:
flags - the flags to set

getClientIPAddress

public int getClientIPAddress()
Returns:
the clientIPAddress

setClientIPAddress

public DHCP setClientIPAddress(int clientIPAddress)
Parameters:
clientIPAddress - the clientIPAddress to set

getYourIPAddress

public int getYourIPAddress()
Returns:
the yourIPAddress

setYourIPAddress

public DHCP setYourIPAddress(int yourIPAddress)
Parameters:
yourIPAddress - the yourIPAddress to set

getServerIPAddress

public int getServerIPAddress()
Returns:
the serverIPAddress

setServerIPAddress

public DHCP setServerIPAddress(int serverIPAddress)
Parameters:
serverIPAddress - the serverIPAddress to set

getGatewayIPAddress

public int getGatewayIPAddress()
Returns:
the gatewayIPAddress

setGatewayIPAddress

public DHCP setGatewayIPAddress(int gatewayIPAddress)
Parameters:
gatewayIPAddress - the gatewayIPAddress to set

getClientHardwareAddress

public byte[] getClientHardwareAddress()
Returns:
the clientHardwareAddress

setClientHardwareAddress

public DHCP setClientHardwareAddress(byte[] clientHardwareAddress)
Parameters:
clientHardwareAddress - the clientHardwareAddress to set

getOption

public DHCPOption getOption(DHCP.DHCPOptionCode optionCode)
Gets a specific DHCP option parameter

Parameters:
opetionCode - The option code to get
Returns:
The value of the option if it exists, null otherwise

getOptions

public java.util.List<DHCPOption> getOptions()
Returns:
the options

setOptions

public DHCP setOptions(java.util.List<DHCPOption> options)
Parameters:
options - the options to set

getPacketType

public DHCPPacketType getPacketType()
Returns:
the packetType base on option 53

getServerName

public java.lang.String getServerName()
Returns:
the serverName

setServerName

public DHCP setServerName(java.lang.String serverName)
Parameters:
serverName - the serverName to set

getBootFileName

public java.lang.String getBootFileName()
Returns:
the bootFileName

setBootFileName

public DHCP setBootFileName(java.lang.String bootFileName)
Parameters:
bootFileName - the bootFileName 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

writeString

protected void writeString(java.lang.String string,
                           java.nio.ByteBuffer bb,
                           int maxLength)

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

readString

protected java.lang.String readString(java.nio.ByteBuffer bb,
                                      int maxLength)