Search in sources :

Example 16 with DhcpResults

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

the class DhcpPacketTest method testMultipleRouters.

@SmallTest
public void testMultipleRouters() throws Exception {
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// Ethernet header.
    "fc3d93000000" + "081735000000" + "0800" + // IP header.
    "45000148c2370000ff117ac2c0a8bd02ffffffff" + // UDP header. TODO: fix invalid checksum (due to MAC address obfuscation).
    "0043004401343beb" + // BOOTP header.
    "0201060027f518e20000800000000000c0a8bd310000000000000000" + // MAC address.
    "fc3d9300000000000000000000000000" + // Server name.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options.
    "638253633501023604c0abbd023304000070803a04000038403b04000062700104ffffff00" + "0308c0a8bd01ffffff0006080808080808080404ff000000000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L2);
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    assertEquals("FC3D93000000", HexDump.toHexString(offerPacket.getClientMac()));
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("192.168.189.49/24", "192.168.189.1", "8.8.8.8,8.8.4.4", null, "192.171.189.2", null, 28800, 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 17 with DhcpResults

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

the class DhcpPacketTest method testUdpServerAnySourcePort.

@SmallTest
public void testUdpServerAnySourcePort() throws Exception {
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// Ethernet header.
    "9cd917000000001c2e0000000800" + // IP header.
    "45a00148000040003d115087d18194fb0a0f7af2" + // NOTE: The server source port is not the canonical port 67.
    "C29F004401341268" + // BOOTP header.
    "02010600d628ba8200000000000000000a0f7af2000000000a0fc818" + // MAC address.
    "9cd91700000000000000000000000000" + // Server name.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options.
    "6382536335010236040a0169fc3304000151800104ffff000003040a0fc817060cd1818003d1819403" + "d18180060f0777766d2e6564751c040a0fffffff000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L2);
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    assertEquals("9CD917000000", HexDump.toHexString(offerPacket.getClientMac()));
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("10.15.122.242/16", "10.15.200.23", "209.129.128.3,209.129.148.3,209.129.128.6", "wvm.edu", "10.1.105.252", null, 86400, 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 18 with DhcpResults

use of android.net.DhcpResults in project platform_frameworks_base by android.

the class DhcpPacketTest method testMultipleRouters.

@SmallTest
public void testMultipleRouters() throws Exception {
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// Ethernet header.
    "fc3d93000000" + "081735000000" + "0800" + // IP header.
    "45000148c2370000ff117ac2c0a8bd02ffffffff" + // UDP header. TODO: fix invalid checksum (due to MAC address obfuscation).
    "0043004401343beb" + // BOOTP header.
    "0201060027f518e20000800000000000c0a8bd310000000000000000" + // MAC address.
    "fc3d9300000000000000000000000000" + // Server name.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options.
    "638253633501023604c0abbd023304000070803a04000038403b04000062700104ffffff00" + "0308c0a8bd01ffffff0006080808080808080404ff000000000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L2);
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    assertEquals("FC3D93000000", HexDump.toHexString(offerPacket.getClientMac()));
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("192.168.189.49/24", "192.168.189.1", "8.8.8.8,8.8.4.4", null, "192.171.189.2", null, 28800, 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 19 with DhcpResults

use of android.net.DhcpResults in project platform_frameworks_base by android.

the class DhcpPacketTest method testPadAndOverloadedOptionsOffer.

@SmallTest
public void testPadAndOverloadedOptionsOffer() throws Exception {
    // A packet observed in the real world that is interesting for two reasons:
    //
    // 1. It uses pad bytes, which we previously didn't support correctly.
    // 2. It uses DHCP option overloading, which we don't currently support (but it doesn't
    //    store any information in the overloaded fields).
    //
    // For now, we just check that it parses correctly.
    final ByteBuffer packet = ByteBuffer.wrap(HexDump.hexStringToByteArray(// Ethernet header.
    "b4cef6000000e80462236e300800" + // IP header.
    "4500014c00000000ff11741701010101ac119876" + // UDP header. TODO: fix invalid checksum (due to MAC address obfuscation).
    "004300440138ae5a" + // BOOTP header.
    "020106000fa0059f0000000000000000ac1198760000000000000000" + // MAC address.
    "b4cef600000000000000000000000000" + // Server name.
    "ff00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
    "ff00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // Options
    "638253633501023604010101010104ffff000033040000a8c03401030304ac1101010604ac110101" + "0000000000000000000000000000000000000000000000ff000000"));
    DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, ENCAP_L2);
    assertTrue(offerPacket instanceof DhcpOfferPacket);
    DhcpResults dhcpResults = offerPacket.toDhcpResults();
    assertDhcpResults("172.17.152.118/16", "172.17.1.1", "172.17.1.1", null, "1.1.1.1", null, 43200, 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 20 with DhcpResults

use of android.net.DhcpResults in project platform_frameworks_base by android.

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)

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