|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dhcp4java.DHCPResponseFactory
public final class DHCPResponseFactory
This class provides some standard factories for DHCP responses.
This simplifies DHCP Server development as basic behaviour is already usable as-is.
Method Summary | |
---|---|
static java.net.InetSocketAddress |
getDefaultSocketAddress(DHCPPacket request,
byte responseType)
Calculates the addres/port to which the response must be sent, according to rfc 2131, section 4.1. |
static DHCPPacket |
makeDHCPAck(DHCPPacket request,
java.net.InetAddress offeredAddress,
int leaseTime,
java.net.InetAddress serverIdentifier,
java.lang.String message,
DHCPOption[] options)
Create a populated DHCPACK response. |
static DHCPPacket |
makeDHCPNak(DHCPPacket request,
java.net.InetAddress serverIdentifier,
java.lang.String message)
Create a populated DHCPNAK response. |
static DHCPPacket |
makeDHCPOffer(DHCPPacket request,
java.net.InetAddress offeredAddress,
int leaseTime,
java.net.InetAddress serverIdentifier,
java.lang.String message,
DHCPOption[] options)
Create a populated DHCPOFFER response. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final DHCPPacket makeDHCPOffer(DHCPPacket request, java.net.InetAddress offeredAddress, int leaseTime, java.net.InetAddress serverIdentifier, java.lang.String message, DHCPOption[] options)
Reponse is populated according to the DHCP request received (must be DHCPDISCOVER), the proposed client address and a set of pre-set options.
Note: getDefaultSocketAddress is called internally to populate address and port number to which response should be sent.
request
- offeredAddress
- options
-
public static final DHCPPacket makeDHCPAck(DHCPPacket request, java.net.InetAddress offeredAddress, int leaseTime, java.net.InetAddress serverIdentifier, java.lang.String message, DHCPOption[] options)
Reponse is populated according to the DHCP request received (must be DHCPREQUEST), the proposed client address and a set of pre-set options.
Note: getDefaultSocketAddress is called internally to populate address and port number to which response should be sent.
request
- offeredAddress
- options
-
public static final DHCPPacket makeDHCPNak(DHCPPacket request, java.net.InetAddress serverIdentifier, java.lang.String message)
Reponse is populated according to the DHCP request received (must be DHCPREQUEST), the proposed client address and a set of pre-set options.
Note: getDefaultSocketAddress is called internally to populate address and port number to which response should be sent.
request
- serverIdentifier
- message
-
public static java.net.InetSocketAddress getDefaultSocketAddress(DHCPPacket request, byte responseType)
This is a method ready to use for *standard* behaviour for any RFC compliant DHCP Server.
If giaddr is null, it is the client's addres/68, otherwise giaddr/67.
Standard behaviour is to set the response packet as follows:
response.setAddrPort(getDefaultSocketAddress(request), response.getOp());
request
- the client DHCP requestresponseType
- the DHCP Message Type the servers wants to send (DHCPOFFER,
DHCPACK, DHCPNAK)
java.lang.IllegalArgumentException
- if request is null.
java.lang.IllegalArgumentException
- if responseType is not valid.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |