use of android.net.DhcpResults in project platform_frameworks_base by android.
the class IpManager method handleIPv4Success.
private void handleIPv4Success(DhcpResults dhcpResults) {
mDhcpResults = new DhcpResults(dhcpResults);
final LinkProperties newLp = assembleLinkProperties();
final ProvisioningChange delta = setLinkProperties(newLp);
if (VDBG) {
Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")");
}
mCallback.onNewDhcpResults(dhcpResults);
dispatchCallback(delta, newLp);
}
use of android.net.DhcpResults in project platform_frameworks_base by android.
the class IpManager method startIPv4.
private boolean startIPv4() {
// handle the result accordingly.
if (mConfiguration.mStaticIpConfig != null) {
if (setIPv4Address(mConfiguration.mStaticIpConfig.ipAddress)) {
handleIPv4Success(new DhcpResults(mConfiguration.mStaticIpConfig));
} else {
return false;
}
} else {
// Start DHCPv4.
mDhcpClient = DhcpClient.makeDhcpClient(mContext, IpManager.this, mInterfaceName);
mDhcpClient.registerForPreDhcpNotification();
mDhcpClient.sendMessage(DhcpClient.CMD_START_DHCP);
}
return true;
}
use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.
the class IpManager method handleIPv4Success.
private void handleIPv4Success(DhcpResults dhcpResults) {
mDhcpResults = new DhcpResults(dhcpResults);
final LinkProperties newLp = assembleLinkProperties();
final ProvisioningChange delta = setLinkProperties(newLp);
if (VDBG) {
Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")");
}
mCallback.onNewDhcpResults(dhcpResults);
dispatchCallback(delta, newLp);
}
use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.
the class DhcpPacketTest method checkIpAddress.
private void checkIpAddress(String expected, byte type, Inet4Address clientIp, Inet4Address yourIp, byte[] netmaskBytes) throws Exception {
ByteBuffer packet = new TestDhcpPacket(type, clientIp, yourIp).setNetmaskBytes(netmaskBytes).build();
DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_BOOTP);
DhcpResults results = offerPacket.toDhcpResults();
if (expected != null) {
LinkAddress expectedAddress = new LinkAddress(expected);
assertEquals(expectedAddress, results.ipAddress);
} else {
assertNull(results);
}
}
use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.
the class DhcpPacketTest method assertLeaseTimeParses.
private void assertLeaseTimeParses(boolean expectValid, Integer rawLeaseTime, long leaseTimeMillis, byte[] leaseTimeBytes) throws Exception {
TestDhcpPacket testPacket = new TestDhcpPacket(DHCP_MESSAGE_TYPE_OFFER);
if (leaseTimeBytes != null) {
testPacket.setLeaseTimeBytes(leaseTimeBytes);
}
ByteBuffer packet = testPacket.build();
DhcpPacket offerPacket = null;
if (!expectValid) {
try {
offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_BOOTP);
fail("Invalid packet parsed successfully: " + offerPacket);
} catch (ParseException expected) {
}
return;
}
offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_BOOTP);
assertNotNull(offerPacket);
assertEquals(rawLeaseTime, offerPacket.mLeaseTime);
// Just check this doesn't crash.
DhcpResults dhcpResults = offerPacket.toDhcpResults();
assertEquals(leaseTimeMillis, offerPacket.getLeaseTimeMillis());
}
Aggregations