Skip to content
Snippets Groups Projects
Commit bd447266 authored by Yang Sun's avatar Yang Sun Committed by Gerrit Code Review
Browse files

Merge "[Test] multicast forwarding from LLA/MLA address test" into main

parents 47d8b2ed 12074b5f
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ import static com.google.common.io.BaseEncoding.base16; ...@@ -41,6 +41,7 @@ import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor; import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assume.assumeNotNull; import static org.junit.Assume.assumeNotNull;
...@@ -450,6 +451,55 @@ public class BorderRoutingTest { ...@@ -450,6 +451,55 @@ public class BorderRoutingTest {
ICMPV6_ECHO_REQUEST_TYPE, ftd.getOmrAddress(), GROUP_ADDR_SCOPE_3)); ICMPV6_ECHO_REQUEST_TYPE, ftd.getOmrAddress(), GROUP_ADDR_SCOPE_3));
} }
@Test
public void multicastRouting_outboundForwarding_llaToScope4IsNotForwarded() throws Exception {
assumeTrue(isKernelVersionAtLeast(KERNEL_VERSION_MULTICAST_ROUTING_SUPPORTED));
/*
* <pre>
* Topology:
* infra network Thread
* infra device -------------------- Border Router -------------- Full Thread device
* (Cuttlefish)
* </pre>
*/
FullThreadDevice ftd = mFtds.get(0);
startFtdChild(ftd);
Inet6Address ftdLla = ftd.getLinkLocalAddress();
assertNotNull(ftdLla);
ftd.ping(GROUP_ADDR_SCOPE_4, ftdLla, 100 /* size */, 1 /* count */);
assertNull(
pollForPacketOnInfraNetwork(ICMPV6_ECHO_REQUEST_TYPE, ftdLla, GROUP_ADDR_SCOPE_4));
}
@Test
public void multicastRouting_outboundForwarding_mlaToScope4IsNotForwarded() throws Exception {
assumeTrue(isKernelVersionAtLeast(KERNEL_VERSION_MULTICAST_ROUTING_SUPPORTED));
/*
* <pre>
* Topology:
* infra network Thread
* infra device -------------------- Border Router -------------- Full Thread device
* (Cuttlefish)
* </pre>
*/
FullThreadDevice ftd = mFtds.get(0);
startFtdChild(ftd);
List<Inet6Address> ftdMlas = ftd.getMeshLocalAddresses();
assertFalse(ftdMlas.isEmpty());
for (Inet6Address ftdMla : ftdMlas) {
ftd.ping(GROUP_ADDR_SCOPE_4, ftdMla, 100 /* size */, 1 /* count */);
assertNull(
pollForPacketOnInfraNetwork(
ICMPV6_ECHO_REQUEST_TYPE, ftdMla, GROUP_ADDR_SCOPE_4));
}
}
@Test @Test
public void multicastRouting_infraNetworkSwitch_ftdRepliesToSubscribedAddress() public void multicastRouting_infraNetworkSwitch_ftdRepliesToSubscribedAddress()
throws Exception { throws Exception {
......
...@@ -106,6 +106,39 @@ public final class FullThreadDevice { ...@@ -106,6 +106,39 @@ public final class FullThreadDevice {
return (Inet6Address) InetAddresses.parseNumericAddress(addresses.get(0)); return (Inet6Address) InetAddresses.parseNumericAddress(addresses.get(0));
} }
/**
* Returns the link-local address of the device.
*
* <p>This methods goes through all unicast addresses on the device and returns the address that
* begins with fe80.
*/
public Inet6Address getLinkLocalAddress() {
List<String> output = executeCommand("ipaddr linklocal");
if (!output.isEmpty() && output.get(0).startsWith("fe80:")) {
return (Inet6Address) InetAddresses.parseNumericAddress(output.get(0));
}
return null;
}
/**
* Returns the mesh-local addresses of the device.
*
* <p>This methods goes through all unicast addresses on the device and returns the address that
* begins with mesh-local prefix.
*/
public List<Inet6Address> getMeshLocalAddresses() {
List<String> addresses = executeCommand("ipaddr");
List<Inet6Address> meshLocalAddresses = new ArrayList<>();
IpPrefix meshLocalPrefix = mActiveOperationalDataset.getMeshLocalPrefix();
for (String address : addresses) {
Inet6Address addr = (Inet6Address) InetAddresses.parseNumericAddress(address);
if (meshLocalPrefix.contains(addr)) {
meshLocalAddresses.add(addr);
}
}
return meshLocalAddresses;
}
/** /**
* Joins the Thread network using the given {@link ActiveOperationalDataset}. * Joins the Thread network using the given {@link ActiveOperationalDataset}.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment