public class DHCPMessage extends Object
| Modifier and Type | Field and Description |
|---|---|
static InetAddress |
BROADCAST_ADDR
Broadcast Adress to send packets to
|
static int |
CLIENT_PORT
Default DHCP client port
|
static byte |
DHCPACK
Message Code representing a DHCPACK message
|
static byte |
DHCPDECLINE
Message Code representing a DHCPDECLINE message
|
static byte |
DHCPDISCOVER
Message Code representing a DHCPDISCOVER message
|
static byte |
DHCPINFORM
Message Code representing a DHCPINFORM message
|
static byte |
DHCPNAK
Message Code representing a DHCPNAK message
|
static byte |
DHCPOFFER
Message Code representing a DHCPOFFER message
|
static byte |
DHCPRELEASE
Message Code representing a DHCPRELEASE message
|
static byte |
DHCPREQUEST
Message Code representing a DHCPREQUEST message
|
static byte |
OP_REPLY
Operation for a reply
|
static byte |
OP_REQUEST
Operation for a request
|
static int |
SERVER_PORT
Default DHCP server port
|
| Constructor and Description |
|---|
DHCPMessage()
Creates empty DHCPMessage object, initializes the object, sets the host
to the broadcast address, the local subnet, binds to the default server
port.
|
DHCPMessage(byte[] ibuf)
Creates an empty DHCPMessage object, initializes the object with a
specified byte array containing DHCP message information, sets the host
to default host name, the local subnet, and bind to the default server
port.
|
DHCPMessage(byte[] ibuf,
InetAddress inServername)
Creates an empty DHCPMessage object, initializes the object with a
specified byte array containing DHCP message information, sets the host
to specified host name, and binds to the specified port.
|
DHCPMessage(byte[] ibuf,
InetAddress inServername,
int inPort)
Creates an empty DHCPMessage object, initializes the object with a
specified byte array containing DHCP message information, sets the host
to specified host name, and binds to the specified port.
|
DHCPMessage(byte[] ibuf,
int inPort)
Creates an empty DHCPMessage object, initializes the object with a
specified byte array containing DHCP message information, sets the host
to broadcast address, and binds to the specified port.
|
DHCPMessage(DataInputStream inStream)
Creates a new DHCPMessage object from the giben DataInputStream.
|
DHCPMessage(DHCPMessage inMessage)
Copy constructor creates DHCPMessage from inMessage
|
DHCPMessage(DHCPMessage inMessage,
InetAddress inServername)
Copy constructor creates DHCPMessage from inMessage and sets server name.
|
DHCPMessage(DHCPMessage inMessage,
InetAddress inServername,
int inPort)
Copy constructor creates DHCPMessage from inMessage and sets server and
port.
|
DHCPMessage(InetAddress inServername)
Creates an empty DHCPMessage object, initializes the object, sets the
host to a specified host name, and binds to the default port.
|
DHCPMessage(InetAddress inServername,
int inPort)
Creates an empty DHCPMessage object, initializes the object, sets the
host to a specified host name, and binds to a specified port.
|
DHCPMessage(int inPort)
Creates an empty DHCPMessage object, initializes the object, sets the
host to the broadcast address, and binds to a specified port.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
externalize()
Converts a DHCPMessage object to a byte array.
|
byte[] |
getChaddr() |
byte[] |
getCiaddr() |
String |
getDestinationAddress()
Get message destination hostname
|
byte[] |
getFile() |
short |
getFlags() |
byte[] |
getGiaddr() |
byte |
getHlen() |
byte |
getHops() |
byte |
getHtype() |
byte |
getOp() |
byte[] |
getOption(int inOptNum)
Returns specified DHCP option that matches the input code.
|
byte[] |
getOptions() |
int |
getPort() |
short |
getSecs() |
byte[] |
getSiaddr() |
byte[] |
getSname() |
int |
getXid() |
byte[] |
getYiaddr() |
DHCPMessage |
internalize(byte[] ibuff)
Convert a specified byte array containing a DHCP message into a
DHCPMessage object.
|
boolean |
IsOptSet(int inOptNum)
Report whether or not the input option is set.
|
void |
removeOption(int inOptNum)
Removes the specified DHCP option that matches the input code.
|
void |
setChaddr(byte[] inChaddr)
Set client harware address.
|
void |
setCiaddr(byte[] inCiaddr)
Set client IP address.
|
void |
setDestinationHost(String inHost)
Set message destination IP
|
void |
setFile(byte[] inFile)
Set boot file name.
|
void |
setFlags(short inFlags)
Set flags field.
|
void |
setGiaddr(byte[] inGiaddr)
Set relay agent IP address.
|
void |
setHlen(byte inHlen)
Set hardware address length.
|
void |
setHops(byte inHops)
Set hops field.
|
void |
setHtype(byte inHtype)
Set hardware address type.
|
void |
setOp(byte inOp)
Set message Op code / message type.
|
void |
setOption(int inOptNum,
byte[] inOptionData)
Sets DHCP options in DHCPMessage.
|
void |
setPort(int inPortNum)
Set message destination port.
|
void |
setSecs(short inSecs)
Set seconds elapsed since client began address acquisition or renewal
process.
|
void |
setSiaddr(byte[] inSiaddr)
Set address of next server to use in bootstrap.
|
void |
setSname(byte[] inSname)
Set optional server host name.
|
void |
setXid(int inXid)
Set transaction ID.
|
void |
setYiaddr(byte[] inYiaddr)
Set 'your' (client) IP address.
|
public static final byte OP_REQUEST
public static final byte OP_REPLY
public static final byte DHCPDISCOVER
public static final byte DHCPOFFER
public static final byte DHCPREQUEST
public static final byte DHCPDECLINE
public static final byte DHCPACK
public static final byte DHCPNAK
public static final byte DHCPRELEASE
public static final byte DHCPINFORM
public static final int CLIENT_PORT
public static final int SERVER_PORT
public static InetAddress BROADCAST_ADDR
public DHCPMessage()
public DHCPMessage(DHCPMessage inMessage)
inMessage - The message to be copiedpublic DHCPMessage(DHCPMessage inMessage, InetAddress inServername, int inPort)
inMessage - The message to be copiedinServername - The host nameinPort - The port numberpublic DHCPMessage(DHCPMessage inMessage, InetAddress inServername)
inMessage - The message to be copiedinServername - The host namepublic DHCPMessage(InetAddress inServername, int inPort)
inServername - The host nameinPort - The port numberpublic DHCPMessage(InetAddress inServername)
inServername - The host namepublic DHCPMessage(int inPort)
inPort - The port numberpublic DHCPMessage(byte[] ibuf)
ibuf - The byte array to initialize DHCPMessage objectpublic DHCPMessage(byte[] ibuf,
InetAddress inServername,
int inPort)
ibuf - The byte array to initialize DHCPMessage objectinServername - The hostnameinPort - The port numberpublic DHCPMessage(byte[] ibuf,
int inPort)
ibuf - The byte array to initialize DHCPMessage objectinPort - The port numberpublic DHCPMessage(byte[] ibuf,
InetAddress inServername)
ibuf - The byte array to initialize DHCPMessage objectinServername - The hostnamepublic DHCPMessage(DataInputStream inStream)
inStream - The stream to read frompublic byte[] externalize()
public DHCPMessage internalize(byte[] ibuff)
ibuff - Byte array to convert to a DHCPMessage objectpublic void setOp(byte inOp)
inOp - message Op code / message typepublic void setHtype(byte inHtype)
inHtype - hardware address typepublic void setHlen(byte inHlen)
inHlen - hardware address lengthpublic void setHops(byte inHops)
inHops - hops fieldpublic void setXid(int inXid)
inXid - transactionIDpublic void setSecs(short inSecs)
inSecs - Seconds elapsed since client began address acquisition or
renewal processpublic void setFlags(short inFlags)
inFlags - flags fieldpublic void setCiaddr(byte[] inCiaddr)
inCiaddr - client IP addresspublic void setYiaddr(byte[] inYiaddr)
inYiaddr - 'your' (client) IP addresspublic void setSiaddr(byte[] inSiaddr)
inSiaddr - address of next server to use in bootstrappublic void setGiaddr(byte[] inGiaddr)
inGiaddr - relay agent IP addresspublic void setChaddr(byte[] inChaddr)
inChaddr - client hardware addresspublic void setSname(byte[] inSname)
inSname - server host namepublic void setFile(byte[] inFile)
inFile - boot file namepublic void setPort(int inPortNum)
inPortNum - port on message destination hostpublic void setDestinationHost(String inHost)
inHost - string representation of message destination IP or hostnamepublic byte getOp()
public byte getHtype()
public byte getHlen()
public byte getHops()
public int getXid()
public short getSecs()
public short getFlags()
public byte[] getCiaddr()
public byte[] getYiaddr()
public byte[] getSiaddr()
public byte[] getGiaddr()
public byte[] getChaddr()
public byte[] getSname()
public byte[] getFile()
public byte[] getOptions()
public int getPort()
public String getDestinationAddress()
public void setOption(int inOptNum,
byte[] inOptionData)
inOptNum - option numberinOptionData - option datapublic byte[] getOption(int inOptNum)
inOptNum - option numberpublic void removeOption(int inOptNum)
inOptNum - option numberpublic boolean IsOptSet(int inOptNum)
inOptNum - option numberCopyright © 2023. All rights reserved.