use of android.net.dhcp.DhcpPacket in project android_frameworks_base by crdroidandroid.
the class DhcpPacketTest method testBadOfferWithoutACookie.
@SmallTest
public void testBadOfferWithoutACookie() throws Exception {
final byte[] packet = HexDump.hexStringToByteArray(// IP header.
"450001518d0600004011144dc0a82b01c0a82bf7" + // UDP header.
"00430044013d9ac7" + // BOOTP header.
"02010600dfc23d1f0002000000000000c0a82bf7c0a82b0100000000" + // MAC address.
"30766ff2a90c00000000000000000000" + // Server name.
"0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + // File.
"0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000");
try {
DhcpPacket offerPacket = DhcpPacket.decodeFullPacket(packet, packet.length, ENCAP_L3);
} catch (DhcpPacket.ParseException expected) {
assertDhcpErrorCodes(DhcpErrorEvent.PARSING_ERROR, expected.errorCode);
return;
}
fail("Dhcp packet parsing should have failed");
}
use of android.net.dhcp.DhcpPacket in project android_frameworks_base by crdroidandroid.
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);
}
Aggregations