public class DHCP extends BasePacket
Modifier and Type | Class and Description |
---|---|
static class |
DHCP.DHCPOptionCode |
Modifier and Type | Field and 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
------------------------------------------
|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 |
parent, payload
Constructor and Description |
---|
DHCP() |
Modifier and Type | Method and Description |
---|---|
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) |
clone, equals, getParent, getPayload, hashCode, resetChecksum, setParent, setPayload
public static int MIN_HEADER_LENGTH
public static byte OPCODE_REQUEST
public static byte OPCODE_REPLY
public static byte HWTYPE_ETHERNET
protected byte opCode
protected byte hardwareType
protected byte hardwareAddressLength
protected byte hops
protected int transactionId
protected short seconds
protected short flags
protected int clientIPAddress
protected int yourIPAddress
protected int serverIPAddress
protected int gatewayIPAddress
protected byte[] clientHardwareAddress
protected java.lang.String serverName
protected java.lang.String bootFileName
protected java.util.List<DHCPOption> options
public byte getOpCode()
public DHCP setOpCode(byte opCode)
opCode
- the opCode to setpublic byte getHardwareType()
public DHCP setHardwareType(byte hardwareType)
hardwareType
- the hardwareType to setpublic byte getHardwareAddressLength()
public DHCP setHardwareAddressLength(byte hardwareAddressLength)
hardwareAddressLength
- the hardwareAddressLength to setpublic byte getHops()
public DHCP setHops(byte hops)
hops
- the hops to setpublic int getTransactionId()
public DHCP setTransactionId(int transactionId)
transactionId
- the transactionId to setpublic short getSeconds()
public DHCP setSeconds(short seconds)
seconds
- the seconds to setpublic short getFlags()
public DHCP setFlags(short flags)
flags
- the flags to setpublic int getClientIPAddress()
public DHCP setClientIPAddress(int clientIPAddress)
clientIPAddress
- the clientIPAddress to setpublic int getYourIPAddress()
public DHCP setYourIPAddress(int yourIPAddress)
yourIPAddress
- the yourIPAddress to setpublic int getServerIPAddress()
public DHCP setServerIPAddress(int serverIPAddress)
serverIPAddress
- the serverIPAddress to setpublic int getGatewayIPAddress()
public DHCP setGatewayIPAddress(int gatewayIPAddress)
gatewayIPAddress
- the gatewayIPAddress to setpublic byte[] getClientHardwareAddress()
public DHCP setClientHardwareAddress(byte[] clientHardwareAddress)
clientHardwareAddress
- the clientHardwareAddress to setpublic DHCPOption getOption(DHCP.DHCPOptionCode optionCode)
optionCode
- The option code to getpublic java.util.List<DHCPOption> getOptions()
public DHCP setOptions(java.util.List<DHCPOption> options)
options
- the options to setpublic DHCPPacketType getPacketType()
public java.lang.String getServerName()
public DHCP setServerName(java.lang.String serverName)
serverName
- the serverName to setpublic java.lang.String getBootFileName()
public DHCP setBootFileName(java.lang.String bootFileName)
bootFileName
- the bootFileName to setpublic byte[] serialize()
IPacket
protected void writeString(java.lang.String string, java.nio.ByteBuffer bb, int maxLength)
public IPacket deserialize(byte[] data, int offset, int length)
IPacket
offset
- offset to start deserializing fromlength
- length of the data to deserializeprotected java.lang.String readString(java.nio.ByteBuffer bb, int maxLength)