Search in sources :

Example 36 with DhcpResults

use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.

the class DhcpPacketTest method checkMtu.

private void checkMtu(ByteBuffer packet, int expectedMtu, byte[] mtuBytes) throws Exception {
    if (mtuBytes != null) {
        packet.position(packet.capacity() - mtuBytes.length);
        packet.put(mtuBytes);
        packet.clear();
    }
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L3);
    // Implicitly checks it's non-null.
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("192.168.159.247/20", "192.168.159.254", "8.8.8.8,8.8.4.4", null, "192.168.144.3", null, 7200, false, expectedMtu, dhcpResults);
}
Also used : DhcpResults(android.net.DhcpResults) DhcpPacket(android.net.dhcp.DhcpPacket)

Example 37 with DhcpResults

use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.

the class DhcpPacketTest method testOffer1.

@SmallTest
public void testOffer1() throws Exception {
    // TODO: Turn all of these into golden files. This will probably require modifying
    // Android.mk appropriately, making this into an AndroidTestCase, and adding code to read
    // the golden files from the test APK's assets via mContext.getAssets().
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// IP header.
    "451001480000000080118849c0a89003c0a89ff7" + // UDP header.
    "004300440134dcfa" + // BOOTP header.
    "02010600c997a63b0000000000000000c0a89ff70000000000000000" + // MAC address.
    "30766ff2a90c00000000000000000000" + // Server name.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options
    "638253633501023604c0a89003330400001c200104fffff0000304c0a89ffe06080808080808080404" + "3a0400000e103b040000189cff00000000000000000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L3);
    // Implicitly checks it's non-null.
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("192.168.159.247/20", "192.168.159.254", "8.8.8.8,8.8.4.4", null, "192.168.144.3", null, 7200, false, 0, dhcpResults);
}
Also used : DhcpResults(android.net.DhcpResults) ByteBuffer(java.nio.ByteBuffer) DhcpPacket(android.net.dhcp.DhcpPacket) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 38 with DhcpResults

use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.

the class DhcpPacketTest method testBug2136.

@SmallTest
public void testBug2136() throws Exception {
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// Ethernet header.
    "bcf5ac000000d0c7890000000800" + // IP header.
    "4500014c00000000ff119beac3eaf3880a3f5d04" + // UDP header. TODO: fix invalid checksum (due to MAC address obfuscation).
    "0043004401387574" + // BOOTP header.
    "0201060163339a3000050000000000000a209ecd0000000000000000" + // MAC address.
    "bcf5ac00000000000000000000000000" + // Server name.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options.
    "6382536335010236040a20ff80330400001c200104fffff00003040a20900106089458413494584135" + "0f0b6c616e63732e61632e756b000000000000000000ff00000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L2);
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    assertEquals("BCF5AC000000", HexDump.toHexString(offerPacket.getClientMac()));
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("10.32.158.205/20", "10.32.144.1", "148.88.65.52,148.88.65.53", "lancs.ac.uk", "10.32.255.128", null, 7200, false, 0, dhcpResults);
}
Also used : DhcpResults(android.net.DhcpResults) ByteBuffer(java.nio.ByteBuffer) DhcpPacket(android.net.dhcp.DhcpPacket) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 39 with DhcpResults

use of android.net.DhcpResults in project android_frameworks_base by DirtyUnicorns.

the class DhcpPacketTest method testBug2111.

@SmallTest
public void testBug2111() throws Exception {
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// IP header.
    "4500014c00000000ff119beac3eaf3880a3f5d04" + // UDP header. TODO: fix invalid checksum (due to MAC address obfuscation).
    "0043004401387464" + // BOOTP header.
    "0201060002554812000a0000000000000a3f5d040000000000000000" + // MAC address.
    "00904c00000000000000000000000000" + // Server name.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options.
    "638253633501023604c00002fe33040000bfc60104fffff00003040a3f50010608c0000201c0000202" + "0f0f646f6d61696e3132332e636f2e756b0000000000ff00000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L3);
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("10.63.93.4/20", "10.63.80.1", "192.0.2.1,192.0.2.2", "domain123.co.uk", "192.0.2.254", null, 49094, false, 0, dhcpResults);
}
Also used : DhcpResults(android.net.DhcpResults) ByteBuffer(java.nio.ByteBuffer) DhcpPacket(android.net.dhcp.DhcpPacket) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 40 with DhcpResults

use of android.net.DhcpResults in project android_frameworks_base by ResurrectionRemix.

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);
}
Also used : DhcpResults(android.net.DhcpResults) ProvisioningChange(android.net.LinkProperties.ProvisioningChange) LinkProperties(android.net.LinkProperties)

Aggregations

DhcpResults (android.net.DhcpResults)55 DhcpPacket (android.net.dhcp.DhcpPacket)40 ByteBuffer (java.nio.ByteBuffer)36 SmallTest (android.test.suitebuilder.annotation.SmallTest)28 LinkAddress (android.net.LinkAddress)9 Inet4Address (java.net.Inet4Address)5 LinkProperties (android.net.LinkProperties)4 ProvisioningChange (android.net.LinkProperties.ProvisioningChange)4 DhcpInfo (android.net.DhcpInfo)1 NetworkInfo (android.net.NetworkInfo)1 RouteInfo (android.net.RouteInfo)1 Message (android.os.Message)1 InetAddress (java.net.InetAddress)1