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 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 List<DhcpOption>
options
protected short
seconds
protected int
serverIPAddress
protected 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
-
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 String serverName
-
bootFileName
protected String bootFileName
-
options
protected 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 List<DhcpOption> getOptions()
- Returns:
- the options
-
setOptions
public DHCP setOptions(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 String getServerName()
- Returns:
- the serverName
-
setServerName
public DHCP setServerName(String server)
- Parameters:
server
- the serverName to set- Returns:
- this
-
getBootFileName
public String getBootFileName()
- Returns:
- the bootFileName
-
setBootFileName
public DHCP setBootFileName(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(String string, ByteBuffer bb, int maxLength)
-
deserializer
public static Deserializer<DHCP> deserializer()
Deserializer function for DHCP packets.- Returns:
- deserializer function
-
-