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 Summary
Nested Classes Modifier and Type Class Description static classDHCP.DHCPOptionCodestatic classDHCP.MsgType
-
Field Summary
Fields 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.BasePacket
parent, payload
-
-
Constructor Summary
Constructors Constructor Description DHCP()
-
Method Summary
All 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.BasePacket
clone, equals, getParent, getPayload, hashCode, resetChecksum, setParent, setPayload
-
-
-
-
Field Detail
-
MIN_HEADER_LENGTH
public 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_REQUEST
public static final byte OPCODE_REQUEST
- See Also:
- Constant Field Values
-
OPCODE_REPLY
public static final byte OPCODE_REPLY
- See Also:
- Constant Field Values
-
HWTYPE_ETHERNET
public static final byte HWTYPE_ETHERNET
- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
getOpCode
public byte getOpCode()
- Returns:
- the opCode
-
setOpCode
public DHCP setOpCode(byte opCode)
- Parameters:
opCode- the opCode to set- Returns:
- this
-
getHardwareType
public byte getHardwareType()
- Returns:
- the hardwareType
-
setHardwareType
public DHCP setHardwareType(byte hardwareType)
- Parameters:
hardwareType- the hardwareType to set- Returns:
- this
-
getHardwareAddressLength
public byte getHardwareAddressLength()
- Returns:
- the hardwareAddressLength
-
setHardwareAddressLength
public DHCP setHardwareAddressLength(byte hardwareAddressLength)
- Parameters:
hardwareAddressLength- the hardwareAddressLength to set- Returns:
- this
-
getHops
public byte getHops()
- Returns:
- the hops
-
setHops
public DHCP setHops(byte hops)
- Parameters:
hops- the hops to set- Returns:
- this
-
getTransactionId
public int getTransactionId()
- Returns:
- the transactionId
-
setTransactionId
public DHCP setTransactionId(int transactionId)
- Parameters:
transactionId- the transactionId to set- Returns:
- this
-
getSeconds
public short getSeconds()
- Returns:
- the seconds
-
setSeconds
public DHCP setSeconds(short seconds)
- Parameters:
seconds- the seconds to set- Returns:
- this
-
getFlags
public short getFlags()
- Returns:
- the flags
-
setFlags
public DHCP setFlags(short flags)
- Parameters:
flags- the flags to set- Returns:
- this
-
getClientIPAddress
public int getClientIPAddress()
- Returns:
- the clientIPAddress
-
setClientIPAddress
public DHCP setClientIPAddress(int clientIPAddress)
- Parameters:
clientIPAddress- the clientIPAddress to set- Returns:
- this
-
getYourIPAddress
public int getYourIPAddress()
- Returns:
- the yourIPAddress
-
setYourIPAddress
public DHCP setYourIPAddress(int yourIPAddress)
- Parameters:
yourIPAddress- the yourIPAddress to set- Returns:
- this
-
getServerIPAddress
public int getServerIPAddress()
- Returns:
- the serverIPAddress
-
setServerIPAddress
public DHCP setServerIPAddress(int serverIPAddress)
- Parameters:
serverIPAddress- the serverIPAddress to set- Returns:
- this
-
getGatewayIPAddress
public int getGatewayIPAddress()
- Returns:
- the gatewayIPAddress
-
setGatewayIPAddress
public DHCP setGatewayIPAddress(int gatewayIPAddress)
- Parameters:
gatewayIPAddress- the gatewayIPAddress to set- Returns:
- this
-
getClientHardwareAddress
public byte[] getClientHardwareAddress()
- Returns:
- the clientHardwareAddress
-
setClientHardwareAddress
public DHCP setClientHardwareAddress(byte[] clientHardwareAddress)
- Parameters:
clientHardwareAddress- the clientHardwareAddress to set- Returns:
- this
-
getOption
public 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
-
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- Returns:
- this
-
getPacketType
public DHCP.MsgType getPacketType()
- Returns:
- the packetType base on option 53
-
getServerName
public java.lang.String getServerName()
- Returns:
- the serverName
-
setServerName
public DHCP setServerName(java.lang.String server)
- Parameters:
server- the serverName to set- Returns:
- this
-
getBootFileName
public java.lang.String getBootFileName()
- Returns:
- the bootFileName
-
setBootFileName
public DHCP setBootFileName(java.lang.String bootFile)
- Parameters:
bootFile- the bootFileName to set- Returns:
- this
-
serialize
public 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
-
writeString
protected void writeString(java.lang.String string, java.nio.ByteBuffer bb, int maxLength)
-
deserializer
public static Deserializer<DHCP> deserializer()
Deserializer function for DHCP packets.- Returns:
- deserializer function
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-