Search in sources :

Example 21 with ApfFilter

use of android.net.apf.ApfFilter in project android_frameworks_base by crdroidandroid.

the class ApfTest method testApfFilterArp.

@LargeTest
public void testApfFilterArp() throws Exception {
    MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
    ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, ALLOW_MULTICAST, mLog);
    // Verify initially ARP request filter is off, and GARP filter is on.
    verifyArpFilter(ipManagerCallback.getApfProgram(), PASS);
    // Inform ApfFilter of our address and verify ARP filtering is on
    LinkAddress linkAddress = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 24);
    LinkProperties lp = new LinkProperties();
    assertTrue(lp.addLinkAddress(linkAddress));
    verifyArpFilter(getProgram(ipManagerCallback, apfFilter, lp), DROP);
    // Inform ApfFilter of loss of IP and verify ARP filtering is off
    verifyArpFilter(getProgram(ipManagerCallback, apfFilter, new LinkProperties()), PASS);
    apfFilter.shutdown();
}
Also used : LinkAddress(android.net.LinkAddress) ApfFilter(android.net.apf.ApfFilter) LinkProperties(android.net.LinkProperties) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Aggregations

ApfFilter (android.net.apf.ApfFilter)21 LinkAddress (android.net.LinkAddress)12 LinkProperties (android.net.LinkProperties)12 LargeTest (android.test.suitebuilder.annotation.LargeTest)12 ByteBuffer (java.nio.ByteBuffer)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)4 IllegalInstructionException (android.net.apf.ApfGenerator.IllegalInstructionException)1 ErrnoException (android.system.ErrnoException)1 IOException (java.io.IOException)1 Random (java.util.Random)1