Snap for 7272189 from 445f742223d8d27cff0e732bf7cd44aa0d26d32a to mainline-media-release
Change-Id: I559f2ee0d9270e9a920744f2f335f2e3c2520fb5
diff --git a/TEST_MAPPING b/TEST_MAPPING
index b840d01..490fb5d 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -14,7 +14,7 @@
"path": "frameworks/base/packages/Tethering"
},
{
- "path": "frameworks/opt/net/wifi"
+ "path": "packages/modules/Wifi/framework"
}
]
-}
\ No newline at end of file
+}
diff --git a/common/device/com/android/net/module/util/Ipv6Utils.java b/common/device/com/android/net/module/util/Ipv6Utils.java
index ee43ae9..fe7c89b 100644
--- a/common/device/com/android/net/module/util/Ipv6Utils.java
+++ b/common/device/com/android/net/module/util/Ipv6Utils.java
@@ -20,6 +20,7 @@
import static com.android.net.module.util.IpUtils.icmpv6Checksum;
import static com.android.net.module.util.NetworkStackConstants.ETHER_TYPE_IPV6;
+import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ECHO_REQUEST_TYPE;
import static com.android.net.module.util.NetworkStackConstants.ICMPV6_NEIGHBOR_ADVERTISEMENT;
import static com.android.net.module.util.NetworkStackConstants.ICMPV6_NEIGHBOR_SOLICITATION;
import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ROUTER_ADVERTISEMENT;
@@ -148,4 +149,14 @@
return buildIcmpv6Packet(srcMac, dstMac, srcIp, dstIp,
(byte) ICMPV6_ROUTER_SOLICITATION /* type */, (byte) 0 /* code */, payload);
}
+
+ /**
+ * Build an ICMPv6 Echo Request packet from the required specified parameters.
+ */
+ public static ByteBuffer buildEchoRequestPacket(final MacAddress srcMac,
+ final MacAddress dstMac, final Inet6Address srcIp, final Inet6Address dstIp) {
+ final ByteBuffer payload = ByteBuffer.allocate(4); // ID and Sequence number may be zero.
+ return buildIcmpv6Packet(srcMac, dstMac, srcIp, dstIp,
+ (byte) ICMPV6_ECHO_REQUEST_TYPE /* type */, (byte) 0 /* code */, payload);
+ }
}
diff --git a/common/framework/com/android/net/module/util/CollectionUtils.java b/common/framework/com/android/net/module/util/CollectionUtils.java
index f2afc75..4fce8f5 100644
--- a/common/framework/com/android/net/module/util/CollectionUtils.java
+++ b/common/framework/com/android/net/module/util/CollectionUtils.java
@@ -156,7 +156,7 @@
* @param test the predicate to test for.
* @return a new collection containing only the source elements that satisfy the predicate.
*/
- @NonNull private static <T> ArrayList<T> filter(@NonNull final Collection<T> source,
+ @NonNull public static <T> ArrayList<T> filter(@NonNull final Collection<T> source,
@NonNull final Predicate<T> test) {
final ArrayList<T> matches = new ArrayList<>();
for (final T e : source) {
diff --git a/common/tests/unit/src/com/android/net/module/util/Ipv6UtilsTest.java b/common/tests/unit/src/com/android/net/module/util/Ipv6UtilsTest.java
index 37278b3..03a1ec9 100644
--- a/common/tests/unit/src/com/android/net/module/util/Ipv6UtilsTest.java
+++ b/common/tests/unit/src/com/android/net/module/util/Ipv6UtilsTest.java
@@ -112,6 +112,25 @@
assertPioEquals(pio, "fdcd:a17f:6502:1::/64", pioFlags, 86400, 86400);
}
+ @Test
+ public void testBuildEchoRequestPacket() {
+ final ByteBuffer b = Ipv6Utils.buildEchoRequestPacket(MAC2, MAC1, LINK_LOCAL, ALL_NODES);
+
+ EthernetHeader eth = Struct.parse(EthernetHeader.class, b);
+ assertEquals(MAC2, eth.srcMac);
+ assertEquals(MAC1, eth.dstMac);
+
+ Ipv6Header ipv6 = Struct.parse(Ipv6Header.class, b);
+ assertEquals(255, ipv6.hopLimit);
+ assertEquals(OsConstants.IPPROTO_ICMPV6, ipv6.nextHeader);
+ assertEquals(LINK_LOCAL, ipv6.srcIp);
+ assertEquals(ALL_NODES, ipv6.dstIp);
+
+ Icmpv6Header icmpv6 = Struct.parse(Icmpv6Header.class, b);
+ assertEquals(NetworkStackConstants.ICMPV6_ECHO_REQUEST_TYPE, icmpv6.type);
+ assertEquals(0, icmpv6.code);
+ }
+
private void assertPioEquals(PrefixInformationOption pio, String prefix, byte flags,
long valid, long preferred) {
assertEquals(NetworkStackConstants.ICMPV6_ND_OPTION_PIO, pio.type);