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 class
DHCP.DHCPOptionCode
static class
DHCP.MsgType
-
Field Summary
Fields Modifier and Type Field Description 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
Dynamic Host Configuration Protocol packet.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 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.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()
DHCP.MsgType
getPacketType()
short
getSeconds()
int
getServerIPAddress()
java.lang.String
getServerName()
int
getTransactionId()
int
getYourIPAddress()
byte[]
serialize()
Sets all payloads parent packet if applicable, then serializes this packet and all payloads.DHCP
setBootFileName(java.lang.String bootFile)
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 server)
DHCP
setTransactionId(int transactionId)
DHCP
setYourIPAddress(int yourIPAddress)
java.lang.String
toString()
protected void
writeString(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: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)
-
deserializer
public static Deserializer<DHCP> deserializer()
Deserializer function for DHCP packets.- Returns:
- deserializer function
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-