DhcpRequestPacketpublic class DhcpRequestPacket extends DhcpPacket This class implements the DHCP-REQUEST packet. |
Constructors Summary |
---|
DhcpRequestPacket(int transId, InetAddress clientIp, byte[] clientMac, boolean broadcast)Generates a REQUEST packet with the specified parameters.
super(transId, clientIp, Inet4Address.ANY, Inet4Address.ANY,
Inet4Address.ANY, clientMac, broadcast);
|
Methods Summary |
---|
public java.nio.ByteBuffer | buildPacket(int encap, short destUdp, short srcUdp)Fills in a packet with the requested REQUEST attributes.
ByteBuffer result = ByteBuffer.allocate(MAX_LENGTH);
fillInPacket(encap, Inet4Address.ALL, Inet4Address.ANY, destUdp, srcUdp,
result, DHCP_BOOTREQUEST, mBroadcast);
result.flip();
return result;
| public void | doNextOp(DhcpStateMachine machine)Notifies the specified state machine of the REQUEST packet parameters.
InetAddress clientRequest =
mRequestedIp == null ? mClientIp : mRequestedIp;
Log.v(TAG, "requested IP is " + mRequestedIp + " and client IP is " +
mClientIp);
machine.onRequestReceived(mBroadcast, mTransId, mClientMac,
clientRequest, mRequestedParams, mHostName);
| void | finishPacket(java.nio.ByteBuffer buffer)Adds the optional parameters to the client-generated REQUEST packet.
byte[] clientId = new byte[7];
// assemble client identifier
clientId[0] = CLIENT_ID_ETHER;
System.arraycopy(mClientMac, 0, clientId, 1, 6);
addTlv(buffer, DHCP_MESSAGE_TYPE, DHCP_MESSAGE_TYPE_REQUEST);
addTlv(buffer, DHCP_PARAMETER_LIST, mRequestedParams);
addTlv(buffer, DHCP_REQUESTED_IP, mRequestedIp);
addTlv(buffer, DHCP_SERVER_IDENTIFIER, mServerIdentifier);
addTlv(buffer, DHCP_CLIENT_IDENTIFIER, clientId);
addTlvEnd(buffer);
| public java.lang.String | toString()
String s = super.toString();
return s + " REQUEST, desired IP " + mRequestedIp + " from host '"
+ mHostName + "', param list length "
+ (mRequestedParams == null ? 0 : mRequestedParams.length);
|
|