Package org.onlab.packet
Class DHCP
- java.lang.Object
- 
- org.onlab.packet.BasePacket
- 
- org.onlab.packet.DHCP
 
 
- 
- All Implemented Interfaces:
- IPacket
 
 public class DHCP extends BasePacket Representation of an DHCP Packet.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classDHCP.DHCPOptionCodestatic classDHCP.MsgType
 - 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringbootFileNameprotected byte[]clientHardwareAddressprotected intclientIPAddressprotected shortflagsprotected intgatewayIPAddressprotected bytehardwareAddressLengthprotected bytehardwareTypeprotected bytehopsstatic byteHWTYPE_ETHERNETstatic intMIN_HEADER_LENGTHDynamic Host Configuration Protocol packet.protected byteopCodestatic byteOPCODE_REPLYstatic byteOPCODE_REQUESTprotected java.util.List<DhcpOption>optionsprotected shortsecondsprotected intserverIPAddressprotected java.lang.StringserverNameprotected inttransactionIdprotected intyourIPAddress- 
Fields inherited from class org.onlab.packet.BasePacketparent, payload
 
- 
 - 
Constructor SummaryConstructors Constructor Description DHCP()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Deserializer<DHCP>deserializer()Deserializer function for DHCP packets.java.lang.StringgetBootFileName()byte[]getClientHardwareAddress()intgetClientIPAddress()shortgetFlags()intgetGatewayIPAddress()bytegetHardwareAddressLength()bytegetHardwareType()bytegetHops()bytegetOpCode()DhcpOptiongetOption(DHCP.DHCPOptionCode optionCode)Gets a specific DHCP option parameter.java.util.List<DhcpOption>getOptions()DHCP.MsgTypegetPacketType()shortgetSeconds()intgetServerIPAddress()java.lang.StringgetServerName()intgetTransactionId()intgetYourIPAddress()byte[]serialize()Sets all payloads parent packet if applicable, then serializes this packet and all payloads.DHCPsetBootFileName(java.lang.String bootFile)DHCPsetClientHardwareAddress(byte[] clientHardwareAddress)DHCPsetClientIPAddress(int clientIPAddress)DHCPsetFlags(short flags)DHCPsetGatewayIPAddress(int gatewayIPAddress)DHCPsetHardwareAddressLength(byte hardwareAddressLength)DHCPsetHardwareType(byte hardwareType)DHCPsetHops(byte hops)DHCPsetOpCode(byte opCode)DHCPsetOptions(java.util.List<DhcpOption> options)DHCPsetSeconds(short seconds)DHCPsetServerIPAddress(int serverIPAddress)DHCPsetServerName(java.lang.String server)DHCPsetTransactionId(int transactionId)DHCPsetYourIPAddress(int yourIPAddress)java.lang.StringtoString()protected voidwriteString(java.lang.String string, java.nio.ByteBuffer bb, int maxLength)- 
Methods inherited from class org.onlab.packet.BasePacketclone, equals, getParent, getPayload, hashCode, resetChecksum, setParent, setPayload
 
- 
 
- 
- 
- 
Field Detail- 
MIN_HEADER_LENGTHpublic static final int MIN_HEADER_LENGTH Dynamic Host Configuration Protocol packet. ------------------------------------------ |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) | ------------------------------------------- See Also:
- Constant Field Values
 
 - 
OPCODE_REQUESTpublic static final byte OPCODE_REQUEST - See Also:
- Constant Field Values
 
 - 
OPCODE_REPLYpublic static final byte OPCODE_REPLY - See Also:
- Constant Field Values
 
 - 
HWTYPE_ETHERNETpublic static final byte HWTYPE_ETHERNET - See Also:
- Constant Field Values
 
 - 
opCodeprotected byte opCode 
 - 
hardwareTypeprotected byte hardwareType 
 - 
hardwareAddressLengthprotected byte hardwareAddressLength 
 - 
hopsprotected byte hops 
 - 
transactionIdprotected int transactionId 
 - 
secondsprotected short seconds 
 - 
flagsprotected short flags 
 - 
clientIPAddressprotected int clientIPAddress 
 - 
yourIPAddressprotected int yourIPAddress 
 - 
serverIPAddressprotected int serverIPAddress 
 - 
gatewayIPAddressprotected int gatewayIPAddress 
 - 
clientHardwareAddressprotected byte[] clientHardwareAddress 
 - 
serverNameprotected java.lang.String serverName 
 - 
bootFileNameprotected java.lang.String bootFileName 
 - 
optionsprotected java.util.List<DhcpOption> options 
 
- 
 - 
Method Detail- 
getOpCodepublic byte getOpCode() - Returns:
- the opCode
 
 - 
setOpCodepublic DHCP setOpCode(byte opCode) - Parameters:
- opCode- the opCode to set
- Returns:
- this
 
 - 
getHardwareTypepublic byte getHardwareType() - Returns:
- the hardwareType
 
 - 
setHardwareTypepublic DHCP setHardwareType(byte hardwareType) - Parameters:
- hardwareType- the hardwareType to set
- Returns:
- this
 
 - 
getHardwareAddressLengthpublic byte getHardwareAddressLength() - Returns:
- the hardwareAddressLength
 
 - 
setHardwareAddressLengthpublic DHCP setHardwareAddressLength(byte hardwareAddressLength) - Parameters:
- hardwareAddressLength- the hardwareAddressLength to set
- Returns:
- this
 
 - 
getHopspublic byte getHops() - Returns:
- the hops
 
 - 
setHopspublic DHCP setHops(byte hops) - Parameters:
- hops- the hops to set
- Returns:
- this
 
 - 
getTransactionIdpublic int getTransactionId() - Returns:
- the transactionId
 
 - 
setTransactionIdpublic DHCP setTransactionId(int transactionId) - Parameters:
- transactionId- the transactionId to set
- Returns:
- this
 
 - 
getSecondspublic short getSeconds() - Returns:
- the seconds
 
 - 
setSecondspublic DHCP setSeconds(short seconds) - Parameters:
- seconds- the seconds to set
- Returns:
- this
 
 - 
getFlagspublic short getFlags() - Returns:
- the flags
 
 - 
setFlagspublic DHCP setFlags(short flags) - Parameters:
- flags- the flags to set
- Returns:
- this
 
 - 
getClientIPAddresspublic int getClientIPAddress() - Returns:
- the clientIPAddress
 
 - 
setClientIPAddresspublic DHCP setClientIPAddress(int clientIPAddress) - Parameters:
- clientIPAddress- the clientIPAddress to set
- Returns:
- this
 
 - 
getYourIPAddresspublic int getYourIPAddress() - Returns:
- the yourIPAddress
 
 - 
setYourIPAddresspublic DHCP setYourIPAddress(int yourIPAddress) - Parameters:
- yourIPAddress- the yourIPAddress to set
- Returns:
- this
 
 - 
getServerIPAddresspublic int getServerIPAddress() - Returns:
- the serverIPAddress
 
 - 
setServerIPAddresspublic DHCP setServerIPAddress(int serverIPAddress) - Parameters:
- serverIPAddress- the serverIPAddress to set
- Returns:
- this
 
 - 
getGatewayIPAddresspublic int getGatewayIPAddress() - Returns:
- the gatewayIPAddress
 
 - 
setGatewayIPAddresspublic DHCP setGatewayIPAddress(int gatewayIPAddress) - Parameters:
- gatewayIPAddress- the gatewayIPAddress to set
- Returns:
- this
 
 - 
getClientHardwareAddresspublic byte[] getClientHardwareAddress() - Returns:
- the clientHardwareAddress
 
 - 
setClientHardwareAddresspublic DHCP setClientHardwareAddress(byte[] clientHardwareAddress) - Parameters:
- clientHardwareAddress- the clientHardwareAddress to set
- Returns:
- this
 
 - 
getOptionpublic DhcpOption getOption(DHCP.DHCPOptionCode optionCode) Gets a specific DHCP option parameter.- Parameters:
- optionCode- The option code to get
- Returns:
- The value of the option if it exists, null otherwise
 
 - 
getOptionspublic java.util.List<DhcpOption> getOptions() - Returns:
- the options
 
 - 
setOptionspublic DHCP setOptions(java.util.List<DhcpOption> options) - Parameters:
- options- the options to set
- Returns:
- this
 
 - 
getPacketTypepublic DHCP.MsgType getPacketType() - Returns:
- the packetType base on option 53
 
 - 
getServerNamepublic java.lang.String getServerName() - Returns:
- the serverName
 
 - 
setServerNamepublic DHCP setServerName(java.lang.String server) - Parameters:
- server- the serverName to set
- Returns:
- this
 
 - 
getBootFileNamepublic java.lang.String getBootFileName() - Returns:
- the bootFileName
 
 - 
setBootFileNamepublic DHCP setBootFileName(java.lang.String bootFile) - Parameters:
- bootFile- the bootFileName to set
- Returns:
- this
 
 - 
serializepublic byte[] serialize() Description copied from interface:IPacketSets all payloads parent packet if applicable, then serializes this packet and all payloads.- Returns:
- a byte[] containing this packet and payloads
 
 - 
writeStringprotected void writeString(java.lang.String string, java.nio.ByteBuffer bb, int maxLength)
 - 
deserializerpublic static Deserializer<DHCP> deserializer() Deserializer function for DHCP packets.- Returns:
- deserializer function
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-