Merge "Support bluetooth not using MultinetworkPolicyTracker" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6a67b8640b
@@ -20,7 +20,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event logged for an interface with APF capabilities when its IpManager state machine exits.
|
* An event logged for an interface with APF capabilities when its IpClient state machine exits.
|
||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public final class ApfStats implements Parcelable {
|
public final class ApfStats implements Parcelable {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import android.net.util.MultinetworkPolicyTracker;
|
|||||||
import android.net.util.NetdService;
|
import android.net.util.NetdService;
|
||||||
import android.net.util.NetworkConstants;
|
import android.net.util.NetworkConstants;
|
||||||
import android.net.util.SharedLog;
|
import android.net.util.SharedLog;
|
||||||
|
import android.os.ConditionVariable;
|
||||||
import android.os.INetworkManagementService;
|
import android.os.INetworkManagementService;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
@@ -150,6 +151,28 @@ public class IpClient extends StateMachine {
|
|||||||
public void setNeighborDiscoveryOffload(boolean enable) {}
|
public void setNeighborDiscoveryOffload(boolean enable) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class WaitForProvisioningCallback extends Callback {
|
||||||
|
private final ConditionVariable mCV = new ConditionVariable();
|
||||||
|
private LinkProperties mCallbackLinkProperties;
|
||||||
|
|
||||||
|
public LinkProperties waitForProvisioning() {
|
||||||
|
mCV.block();
|
||||||
|
return mCallbackLinkProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProvisioningSuccess(LinkProperties newLp) {
|
||||||
|
mCallbackLinkProperties = newLp;
|
||||||
|
mCV.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProvisioningFailure(LinkProperties newLp) {
|
||||||
|
mCallbackLinkProperties = null;
|
||||||
|
mCV.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Use a wrapper class to log in order to ensure complete and detailed
|
// Use a wrapper class to log in order to ensure complete and detailed
|
||||||
// logging. This method is lighter weight than annotations/reflection
|
// logging. This method is lighter weight than annotations/reflection
|
||||||
// and has the following benefits:
|
// and has the following benefits:
|
||||||
@@ -281,6 +304,11 @@ public class IpClient extends StateMachine {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder withoutMultinetworkPolicyTracker() {
|
||||||
|
mConfig.mUsingMultinetworkPolicyTracker = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder withoutIpReachabilityMonitor() {
|
public Builder withoutIpReachabilityMonitor() {
|
||||||
mConfig.mUsingIpReachabilityMonitor = false;
|
mConfig.mUsingIpReachabilityMonitor = false;
|
||||||
return this;
|
return this;
|
||||||
@@ -343,6 +371,7 @@ public class IpClient extends StateMachine {
|
|||||||
|
|
||||||
/* package */ boolean mEnableIPv4 = true;
|
/* package */ boolean mEnableIPv4 = true;
|
||||||
/* package */ boolean mEnableIPv6 = true;
|
/* package */ boolean mEnableIPv6 = true;
|
||||||
|
/* package */ boolean mUsingMultinetworkPolicyTracker = true;
|
||||||
/* package */ boolean mUsingIpReachabilityMonitor = true;
|
/* package */ boolean mUsingIpReachabilityMonitor = true;
|
||||||
/* package */ int mRequestedPreDhcpActionMs;
|
/* package */ int mRequestedPreDhcpActionMs;
|
||||||
/* package */ InitialConfiguration mInitialConfig;
|
/* package */ InitialConfiguration mInitialConfig;
|
||||||
@@ -374,6 +403,7 @@ public class IpClient extends StateMachine {
|
|||||||
return new StringJoiner(", ", getClass().getSimpleName() + "{", "}")
|
return new StringJoiner(", ", getClass().getSimpleName() + "{", "}")
|
||||||
.add("mEnableIPv4: " + mEnableIPv4)
|
.add("mEnableIPv4: " + mEnableIPv4)
|
||||||
.add("mEnableIPv6: " + mEnableIPv6)
|
.add("mEnableIPv6: " + mEnableIPv6)
|
||||||
|
.add("mUsingMultinetworkPolicyTracker: " + mUsingMultinetworkPolicyTracker)
|
||||||
.add("mUsingIpReachabilityMonitor: " + mUsingIpReachabilityMonitor)
|
.add("mUsingIpReachabilityMonitor: " + mUsingIpReachabilityMonitor)
|
||||||
.add("mRequestedPreDhcpActionMs: " + mRequestedPreDhcpActionMs)
|
.add("mRequestedPreDhcpActionMs: " + mRequestedPreDhcpActionMs)
|
||||||
.add("mInitialConfig: " + mInitialConfig)
|
.add("mInitialConfig: " + mInitialConfig)
|
||||||
@@ -559,7 +589,6 @@ public class IpClient extends StateMachine {
|
|||||||
private final NetlinkTracker mNetlinkTracker;
|
private final NetlinkTracker mNetlinkTracker;
|
||||||
private final WakeupMessage mProvisioningTimeoutAlarm;
|
private final WakeupMessage mProvisioningTimeoutAlarm;
|
||||||
private final WakeupMessage mDhcpActionTimeoutAlarm;
|
private final WakeupMessage mDhcpActionTimeoutAlarm;
|
||||||
private final MultinetworkPolicyTracker mMultinetworkPolicyTracker;
|
|
||||||
private final SharedLog mLog;
|
private final SharedLog mLog;
|
||||||
private final LocalLog mConnectivityPacketLog;
|
private final LocalLog mConnectivityPacketLog;
|
||||||
private final MessageHandlingLogger mMsgStateLogger;
|
private final MessageHandlingLogger mMsgStateLogger;
|
||||||
@@ -573,6 +602,7 @@ public class IpClient extends StateMachine {
|
|||||||
*/
|
*/
|
||||||
private LinkProperties mLinkProperties;
|
private LinkProperties mLinkProperties;
|
||||||
private ProvisioningConfiguration mConfiguration;
|
private ProvisioningConfiguration mConfiguration;
|
||||||
|
private MultinetworkPolicyTracker mMultinetworkPolicyTracker;
|
||||||
private IpReachabilityMonitor mIpReachabilityMonitor;
|
private IpReachabilityMonitor mIpReachabilityMonitor;
|
||||||
private DhcpClient mDhcpClient;
|
private DhcpClient mDhcpClient;
|
||||||
private DhcpResults mDhcpResults;
|
private DhcpResults mDhcpResults;
|
||||||
@@ -685,9 +715,6 @@ public class IpClient extends StateMachine {
|
|||||||
mLinkProperties = new LinkProperties();
|
mLinkProperties = new LinkProperties();
|
||||||
mLinkProperties.setInterfaceName(mInterfaceName);
|
mLinkProperties.setInterfaceName(mInterfaceName);
|
||||||
|
|
||||||
mMultinetworkPolicyTracker = new MultinetworkPolicyTracker(mContext, getHandler(),
|
|
||||||
() -> { mLog.log("OBSERVED AvoidBadWifi changed"); });
|
|
||||||
|
|
||||||
mProvisioningTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
mProvisioningTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
||||||
mTag + ".EVENT_PROVISIONING_TIMEOUT", EVENT_PROVISIONING_TIMEOUT);
|
mTag + ".EVENT_PROVISIONING_TIMEOUT", EVENT_PROVISIONING_TIMEOUT);
|
||||||
mDhcpActionTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
mDhcpActionTimeoutAlarm = new WakeupMessage(mContext, getHandler(),
|
||||||
@@ -719,8 +746,6 @@ public class IpClient extends StateMachine {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
logError("Couldn't register NetlinkTracker: %s", e);
|
logError("Couldn't register NetlinkTracker: %s", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMultinetworkPolicyTracker.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopStateMachineUpdaters() {
|
private void stopStateMachineUpdaters() {
|
||||||
@@ -729,8 +754,6 @@ public class IpClient extends StateMachine {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
logError("Couldn't unregister NetlinkTracker: %s", e);
|
logError("Couldn't unregister NetlinkTracker: %s", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMultinetworkPolicyTracker.shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1028,7 +1051,8 @@ public class IpClient extends StateMachine {
|
|||||||
// Note that we can still be disconnected by IpReachabilityMonitor
|
// Note that we can still be disconnected by IpReachabilityMonitor
|
||||||
// if the IPv6 default gateway (but not the IPv6 DNS servers; see
|
// if the IPv6 default gateway (but not the IPv6 DNS servers; see
|
||||||
// accompanying code in IpReachabilityMonitor) is unreachable.
|
// accompanying code in IpReachabilityMonitor) is unreachable.
|
||||||
final boolean ignoreIPv6ProvisioningLoss = !mMultinetworkPolicyTracker.getAvoidBadWifi();
|
final boolean ignoreIPv6ProvisioningLoss = (mMultinetworkPolicyTracker != null)
|
||||||
|
&& !mMultinetworkPolicyTracker.getAvoidBadWifi();
|
||||||
|
|
||||||
// Additionally:
|
// Additionally:
|
||||||
//
|
//
|
||||||
@@ -1520,6 +1544,13 @@ public class IpClient extends StateMachine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mConfiguration.mUsingMultinetworkPolicyTracker) {
|
||||||
|
mMultinetworkPolicyTracker = new MultinetworkPolicyTracker(
|
||||||
|
mContext, getHandler(),
|
||||||
|
() -> { mLog.log("OBSERVED AvoidBadWifi changed"); });
|
||||||
|
mMultinetworkPolicyTracker.start();
|
||||||
|
}
|
||||||
|
|
||||||
if (mConfiguration.mUsingIpReachabilityMonitor && !startIpReachabilityMonitor()) {
|
if (mConfiguration.mUsingIpReachabilityMonitor && !startIpReachabilityMonitor()) {
|
||||||
doImmediateProvisioningFailure(
|
doImmediateProvisioningFailure(
|
||||||
IpManagerEvent.ERROR_STARTING_IPREACHABILITYMONITOR);
|
IpManagerEvent.ERROR_STARTING_IPREACHABILITYMONITOR);
|
||||||
@@ -1537,6 +1568,11 @@ public class IpClient extends StateMachine {
|
|||||||
mIpReachabilityMonitor = null;
|
mIpReachabilityMonitor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mMultinetworkPolicyTracker != null) {
|
||||||
|
mMultinetworkPolicyTracker.shutdown();
|
||||||
|
mMultinetworkPolicyTracker = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (mDhcpClient != null) {
|
if (mDhcpClient != null) {
|
||||||
mDhcpClient.sendMessage(DhcpClient.CMD_STOP_DHCP);
|
mDhcpClient.sendMessage(DhcpClient.CMD_STOP_DHCP);
|
||||||
mDhcpClient.doQuit();
|
mDhcpClient.doQuit();
|
||||||
|
|||||||
@@ -114,35 +114,6 @@ public class IpManager extends IpClient {
|
|||||||
public static class Callback extends IpClient.Callback {
|
public static class Callback extends IpClient.Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WaitForProvisioningCallback extends Callback {
|
|
||||||
private LinkProperties mCallbackLinkProperties;
|
|
||||||
|
|
||||||
public LinkProperties waitForProvisioning() {
|
|
||||||
synchronized (this) {
|
|
||||||
try {
|
|
||||||
wait();
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
return mCallbackLinkProperties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProvisioningSuccess(LinkProperties newLp) {
|
|
||||||
synchronized (this) {
|
|
||||||
mCallbackLinkProperties = newLp;
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProvisioningFailure(LinkProperties newLp) {
|
|
||||||
synchronized (this) {
|
|
||||||
mCallbackLinkProperties = null;
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IpManager(Context context, String ifName, Callback callback) {
|
public IpManager(Context context, String ifName, Callback callback) {
|
||||||
super(context, ifName, callback);
|
super(context, ifName, callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import android.net.NetworkUtils;
|
|||||||
import android.net.apf.ApfFilter.ApfConfiguration;
|
import android.net.apf.ApfFilter.ApfConfiguration;
|
||||||
import android.net.apf.ApfGenerator.IllegalInstructionException;
|
import android.net.apf.ApfGenerator.IllegalInstructionException;
|
||||||
import android.net.apf.ApfGenerator.Register;
|
import android.net.apf.ApfGenerator.Register;
|
||||||
import android.net.ip.IpManager;
|
import android.net.ip.IpClient;
|
||||||
import android.net.metrics.IpConnectivityLog;
|
import android.net.metrics.IpConnectivityLog;
|
||||||
import android.net.metrics.RaEvent;
|
import android.net.metrics.RaEvent;
|
||||||
import android.net.util.InterfaceParams;
|
import android.net.util.InterfaceParams;
|
||||||
@@ -606,7 +606,7 @@ public class ApfTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MockIpManagerCallback extends IpManager.Callback {
|
private class MockIpClientCallback extends IpClient.Callback {
|
||||||
private final ConditionVariable mGotApfProgram = new ConditionVariable();
|
private final ConditionVariable mGotApfProgram = new ConditionVariable();
|
||||||
private byte[] mLastApfProgram;
|
private byte[] mLastApfProgram;
|
||||||
|
|
||||||
@@ -637,8 +637,8 @@ public class ApfTest {
|
|||||||
private final long mFixedTimeMs = SystemClock.elapsedRealtime();
|
private final long mFixedTimeMs = SystemClock.elapsedRealtime();
|
||||||
|
|
||||||
public TestApfFilter(Context context, ApfConfiguration config,
|
public TestApfFilter(Context context, ApfConfiguration config,
|
||||||
IpManager.Callback ipManagerCallback, IpConnectivityLog log) throws Exception {
|
IpClient.Callback ipClientCallback, IpConnectivityLog log) throws Exception {
|
||||||
super(context, config, InterfaceParams.getByName("lo"), ipManagerCallback, log);
|
super(context, config, InterfaceParams.getByName("lo"), ipClientCallback, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pretend an RA packet has been received and show it to ApfFilter.
|
// Pretend an RA packet has been received and show it to ApfFilter.
|
||||||
@@ -761,29 +761,29 @@ public class ApfTest {
|
|||||||
private static final byte[] IPV4_ANY_HOST_ADDR = {0, 0, 0, 0};
|
private static final byte[] IPV4_ANY_HOST_ADDR = {0, 0, 0, 0};
|
||||||
|
|
||||||
// Helper to initialize a default apfFilter.
|
// Helper to initialize a default apfFilter.
|
||||||
private ApfFilter setupApfFilter(IpManager.Callback ipManagerCallback, ApfConfiguration config)
|
private ApfFilter setupApfFilter(IpClient.Callback ipClientCallback, ApfConfiguration config)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19);
|
LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19);
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
lp.addLinkAddress(link);
|
lp.addLinkAddress(link);
|
||||||
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
apfFilter.setLinkProperties(lp);
|
apfFilter.setLinkProperties(lp);
|
||||||
return apfFilter;
|
return apfFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApfFilterIPv4() throws Exception {
|
public void testApfFilterIPv4() throws Exception {
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19);
|
LinkAddress link = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 19);
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
lp.addLinkAddress(link);
|
lp.addLinkAddress(link);
|
||||||
|
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
config.multicastFilter = DROP_MULTICAST;
|
config.multicastFilter = DROP_MULTICAST;
|
||||||
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
apfFilter.setLinkProperties(lp);
|
apfFilter.setLinkProperties(lp);
|
||||||
|
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify empty packet of 100 zero bytes is passed
|
// Verify empty packet of 100 zero bytes is passed
|
||||||
ByteBuffer packet = ByteBuffer.wrap(new byte[100]);
|
ByteBuffer packet = ByteBuffer.wrap(new byte[100]);
|
||||||
@@ -830,10 +830,10 @@ public class ApfTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApfFilterIPv6() throws Exception {
|
public void testApfFilterIPv6() throws Exception {
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify empty IPv6 packet is passed
|
// Verify empty IPv6 packet is passed
|
||||||
ByteBuffer packet = ByteBuffer.wrap(new byte[100]);
|
ByteBuffer packet = ByteBuffer.wrap(new byte[100]);
|
||||||
@@ -868,17 +868,17 @@ public class ApfTest {
|
|||||||
final byte[] multicastIpv4Addr = {(byte)224,0,0,1};
|
final byte[] multicastIpv4Addr = {(byte)224,0,0,1};
|
||||||
final byte[] multicastIpv6Addr = {(byte)0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte)0xfb};
|
final byte[] multicastIpv6Addr = {(byte)0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte)0xfb};
|
||||||
|
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
LinkAddress link = new LinkAddress(InetAddress.getByAddress(unicastIpv4Addr), 24);
|
LinkAddress link = new LinkAddress(InetAddress.getByAddress(unicastIpv4Addr), 24);
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
lp.addLinkAddress(link);
|
lp.addLinkAddress(link);
|
||||||
|
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
apfFilter.setLinkProperties(lp);
|
apfFilter.setLinkProperties(lp);
|
||||||
|
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Construct IPv4 and IPv6 multicast packets.
|
// Construct IPv4 and IPv6 multicast packets.
|
||||||
ByteBuffer mcastv4packet = ByteBuffer.wrap(new byte[100]);
|
ByteBuffer mcastv4packet = ByteBuffer.wrap(new byte[100]);
|
||||||
@@ -915,9 +915,9 @@ public class ApfTest {
|
|||||||
assertPass(program, bcastv4unicastl2packet.array());
|
assertPass(program, bcastv4unicastl2packet.array());
|
||||||
|
|
||||||
// Turn on multicast filter and verify it works
|
// Turn on multicast filter and verify it works
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.setMulticastFilter(true);
|
apfFilter.setMulticastFilter(true);
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
assertDrop(program, mcastv4packet.array());
|
assertDrop(program, mcastv4packet.array());
|
||||||
assertDrop(program, mcastv6packet.array());
|
assertDrop(program, mcastv6packet.array());
|
||||||
assertDrop(program, bcastv4packet1.array());
|
assertDrop(program, bcastv4packet1.array());
|
||||||
@@ -925,9 +925,9 @@ public class ApfTest {
|
|||||||
assertDrop(program, bcastv4unicastl2packet.array());
|
assertDrop(program, bcastv4unicastl2packet.array());
|
||||||
|
|
||||||
// Turn off multicast filter and verify it's off
|
// Turn off multicast filter and verify it's off
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.setMulticastFilter(false);
|
apfFilter.setMulticastFilter(false);
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
assertPass(program, mcastv4packet.array());
|
assertPass(program, mcastv4packet.array());
|
||||||
assertPass(program, mcastv6packet.array());
|
assertPass(program, mcastv6packet.array());
|
||||||
assertPass(program, bcastv4packet1.array());
|
assertPass(program, bcastv4packet1.array());
|
||||||
@@ -935,13 +935,13 @@ public class ApfTest {
|
|||||||
assertPass(program, bcastv4unicastl2packet.array());
|
assertPass(program, bcastv4unicastl2packet.array());
|
||||||
|
|
||||||
// Verify it can be initialized to on
|
// Verify it can be initialized to on
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
config.multicastFilter = DROP_MULTICAST;
|
config.multicastFilter = DROP_MULTICAST;
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
apfFilter.setLinkProperties(lp);
|
apfFilter.setLinkProperties(lp);
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
assertDrop(program, mcastv4packet.array());
|
assertDrop(program, mcastv4packet.array());
|
||||||
assertDrop(program, mcastv6packet.array());
|
assertDrop(program, mcastv6packet.array());
|
||||||
assertDrop(program, bcastv4packet1.array());
|
assertDrop(program, bcastv4packet1.array());
|
||||||
@@ -956,8 +956,8 @@ public class ApfTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApfFilterMulticastPingWhileDozing() throws Exception {
|
public void testApfFilterMulticastPingWhileDozing() throws Exception {
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
ApfFilter apfFilter = setupApfFilter(ipManagerCallback, getDefaultConfig());
|
ApfFilter apfFilter = setupApfFilter(ipClientCallback, getDefaultConfig());
|
||||||
|
|
||||||
// Construct a multicast ICMPv6 ECHO request.
|
// Construct a multicast ICMPv6 ECHO request.
|
||||||
final byte[] multicastIpv6Addr = {(byte)0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte)0xfb};
|
final byte[] multicastIpv6Addr = {(byte)0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte)0xfb};
|
||||||
@@ -968,35 +968,35 @@ public class ApfTest {
|
|||||||
put(packet, IPV6_DEST_ADDR_OFFSET, multicastIpv6Addr);
|
put(packet, IPV6_DEST_ADDR_OFFSET, multicastIpv6Addr);
|
||||||
|
|
||||||
// Normally, we let multicast pings alone...
|
// Normally, we let multicast pings alone...
|
||||||
assertPass(ipManagerCallback.getApfProgram(), packet.array());
|
assertPass(ipClientCallback.getApfProgram(), packet.array());
|
||||||
|
|
||||||
// ...and even while dozing...
|
// ...and even while dozing...
|
||||||
apfFilter.setDozeMode(true);
|
apfFilter.setDozeMode(true);
|
||||||
assertPass(ipManagerCallback.getApfProgram(), packet.array());
|
assertPass(ipClientCallback.getApfProgram(), packet.array());
|
||||||
|
|
||||||
// ...but when the multicast filter is also enabled, drop the multicast pings to save power.
|
// ...but when the multicast filter is also enabled, drop the multicast pings to save power.
|
||||||
apfFilter.setMulticastFilter(true);
|
apfFilter.setMulticastFilter(true);
|
||||||
assertDrop(ipManagerCallback.getApfProgram(), packet.array());
|
assertDrop(ipClientCallback.getApfProgram(), packet.array());
|
||||||
|
|
||||||
// However, we should still let through all other ICMPv6 types.
|
// However, we should still let through all other ICMPv6 types.
|
||||||
ByteBuffer raPacket = ByteBuffer.wrap(packet.array().clone());
|
ByteBuffer raPacket = ByteBuffer.wrap(packet.array().clone());
|
||||||
raPacket.put(ICMP6_TYPE_OFFSET, (byte)ICMPV6_ROUTER_ADVERTISEMENT);
|
raPacket.put(ICMP6_TYPE_OFFSET, (byte)ICMPV6_ROUTER_ADVERTISEMENT);
|
||||||
assertPass(ipManagerCallback.getApfProgram(), raPacket.array());
|
assertPass(ipClientCallback.getApfProgram(), raPacket.array());
|
||||||
|
|
||||||
// Now wake up from doze mode to ensure that we no longer drop the packets.
|
// Now wake up from doze mode to ensure that we no longer drop the packets.
|
||||||
// (The multicast filter is still enabled at this point).
|
// (The multicast filter is still enabled at this point).
|
||||||
apfFilter.setDozeMode(false);
|
apfFilter.setDozeMode(false);
|
||||||
assertPass(ipManagerCallback.getApfProgram(), packet.array());
|
assertPass(ipClientCallback.getApfProgram(), packet.array());
|
||||||
|
|
||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApfFilter802_3() throws Exception {
|
public void testApfFilter802_3() throws Exception {
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
ApfFilter apfFilter = setupApfFilter(ipManagerCallback, config);
|
ApfFilter apfFilter = setupApfFilter(ipClientCallback, config);
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify empty packet of 100 zero bytes is passed
|
// Verify empty packet of 100 zero bytes is passed
|
||||||
// Note that eth-type = 0 makes it an IEEE802.3 frame
|
// Note that eth-type = 0 makes it an IEEE802.3 frame
|
||||||
@@ -1012,11 +1012,11 @@ public class ApfTest {
|
|||||||
assertPass(program, packet.array());
|
assertPass(program, packet.array());
|
||||||
|
|
||||||
// Now turn on the filter
|
// Now turn on the filter
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
apfFilter = setupApfFilter(ipManagerCallback, config);
|
apfFilter = setupApfFilter(ipClientCallback, config);
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify that IEEE802.3 frame is dropped
|
// Verify that IEEE802.3 frame is dropped
|
||||||
// In this case ethtype is used for payload length
|
// In this case ethtype is used for payload length
|
||||||
@@ -1040,10 +1040,10 @@ public class ApfTest {
|
|||||||
final int[] ipv4BlackList = {ETH_P_IP};
|
final int[] ipv4BlackList = {ETH_P_IP};
|
||||||
final int[] ipv4Ipv6BlackList = {ETH_P_IP, ETH_P_IPV6};
|
final int[] ipv4Ipv6BlackList = {ETH_P_IP, ETH_P_IPV6};
|
||||||
|
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
ApfFilter apfFilter = setupApfFilter(ipManagerCallback, config);
|
ApfFilter apfFilter = setupApfFilter(ipClientCallback, config);
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify empty packet of 100 zero bytes is passed
|
// Verify empty packet of 100 zero bytes is passed
|
||||||
// Note that eth-type = 0 makes it an IEEE802.3 frame
|
// Note that eth-type = 0 makes it an IEEE802.3 frame
|
||||||
@@ -1059,11 +1059,11 @@ public class ApfTest {
|
|||||||
assertPass(program, packet.array());
|
assertPass(program, packet.array());
|
||||||
|
|
||||||
// Now add IPv4 to the black list
|
// Now add IPv4 to the black list
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
config.ethTypeBlackList = ipv4BlackList;
|
config.ethTypeBlackList = ipv4BlackList;
|
||||||
apfFilter = setupApfFilter(ipManagerCallback, config);
|
apfFilter = setupApfFilter(ipClientCallback, config);
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify that IPv4 frame will be dropped
|
// Verify that IPv4 frame will be dropped
|
||||||
packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
|
packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
|
||||||
@@ -1074,11 +1074,11 @@ public class ApfTest {
|
|||||||
assertPass(program, packet.array());
|
assertPass(program, packet.array());
|
||||||
|
|
||||||
// Now let us have both IPv4 and IPv6 in the black list
|
// Now let us have both IPv4 and IPv6 in the black list
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
config.ethTypeBlackList = ipv4Ipv6BlackList;
|
config.ethTypeBlackList = ipv4Ipv6BlackList;
|
||||||
apfFilter = setupApfFilter(ipManagerCallback, config);
|
apfFilter = setupApfFilter(ipClientCallback, config);
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
// Verify that IPv4 frame will be dropped
|
// Verify that IPv4 frame will be dropped
|
||||||
packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
|
packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
|
||||||
@@ -1091,7 +1091,7 @@ public class ApfTest {
|
|||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] getProgram(MockIpManagerCallback cb, ApfFilter filter, LinkProperties lp) {
|
private byte[] getProgram(MockIpClientCallback cb, ApfFilter filter, LinkProperties lp) {
|
||||||
cb.resetApfProgramWait();
|
cb.resetApfProgramWait();
|
||||||
filter.setLinkProperties(lp);
|
filter.setLinkProperties(lp);
|
||||||
return cb.getApfProgram();
|
return cb.getApfProgram();
|
||||||
@@ -1114,23 +1114,23 @@ public class ApfTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApfFilterArp() throws Exception {
|
public void testApfFilterArp() throws Exception {
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
config.multicastFilter = DROP_MULTICAST;
|
config.multicastFilter = DROP_MULTICAST;
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
|
|
||||||
// Verify initially ARP request filter is off, and GARP filter is on.
|
// Verify initially ARP request filter is off, and GARP filter is on.
|
||||||
verifyArpFilter(ipManagerCallback.getApfProgram(), PASS);
|
verifyArpFilter(ipClientCallback.getApfProgram(), PASS);
|
||||||
|
|
||||||
// Inform ApfFilter of our address and verify ARP filtering is on
|
// Inform ApfFilter of our address and verify ARP filtering is on
|
||||||
LinkAddress linkAddress = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 24);
|
LinkAddress linkAddress = new LinkAddress(InetAddress.getByAddress(MOCK_IPV4_ADDR), 24);
|
||||||
LinkProperties lp = new LinkProperties();
|
LinkProperties lp = new LinkProperties();
|
||||||
assertTrue(lp.addLinkAddress(linkAddress));
|
assertTrue(lp.addLinkAddress(linkAddress));
|
||||||
verifyArpFilter(getProgram(ipManagerCallback, apfFilter, lp), DROP);
|
verifyArpFilter(getProgram(ipClientCallback, apfFilter, lp), DROP);
|
||||||
|
|
||||||
// Inform ApfFilter of loss of IP and verify ARP filtering is off
|
// Inform ApfFilter of loss of IP and verify ARP filtering is off
|
||||||
verifyArpFilter(getProgram(ipManagerCallback, apfFilter, new LinkProperties()), PASS);
|
verifyArpFilter(getProgram(ipClientCallback, apfFilter, new LinkProperties()), PASS);
|
||||||
|
|
||||||
apfFilter.shutdown();
|
apfFilter.shutdown();
|
||||||
}
|
}
|
||||||
@@ -1161,7 +1161,7 @@ public class ApfTest {
|
|||||||
return packet.array();
|
return packet.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the last program pushed to the IpManager.Callback properly filters the
|
// Verify that the last program pushed to the IpClient.Callback properly filters the
|
||||||
// given packet for the given lifetime.
|
// given packet for the given lifetime.
|
||||||
private void verifyRaLifetime(byte[] program, ByteBuffer packet, int lifetime) {
|
private void verifyRaLifetime(byte[] program, ByteBuffer packet, int lifetime) {
|
||||||
final int FRACTION_OF_LIFETIME = 6;
|
final int FRACTION_OF_LIFETIME = 6;
|
||||||
@@ -1191,12 +1191,12 @@ public class ApfTest {
|
|||||||
|
|
||||||
// Test that when ApfFilter is shown the given packet, it generates a program to filter it
|
// Test that when ApfFilter is shown the given packet, it generates a program to filter it
|
||||||
// for the given lifetime.
|
// for the given lifetime.
|
||||||
private void verifyRaLifetime(TestApfFilter apfFilter, MockIpManagerCallback ipManagerCallback,
|
private void verifyRaLifetime(TestApfFilter apfFilter, MockIpClientCallback ipClientCallback,
|
||||||
ByteBuffer packet, int lifetime) throws IOException, ErrnoException {
|
ByteBuffer packet, int lifetime) throws IOException, ErrnoException {
|
||||||
// Verify new program generated if ApfFilter witnesses RA
|
// Verify new program generated if ApfFilter witnesses RA
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.pretendPacketReceived(packet.array());
|
apfFilter.pretendPacketReceived(packet.array());
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
verifyRaLifetime(program, packet, lifetime);
|
verifyRaLifetime(program, packet, lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1229,21 +1229,21 @@ public class ApfTest {
|
|||||||
&& (ev1.dnsslLifetime == ev2.dnsslLifetime);
|
&& (ev1.dnsslLifetime == ev2.dnsslLifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertInvalidRa(TestApfFilter apfFilter, MockIpManagerCallback ipManagerCallback,
|
private void assertInvalidRa(TestApfFilter apfFilter, MockIpClientCallback ipClientCallback,
|
||||||
ByteBuffer packet) throws IOException, ErrnoException {
|
ByteBuffer packet) throws IOException, ErrnoException {
|
||||||
ipManagerCallback.resetApfProgramWait();
|
ipClientCallback.resetApfProgramWait();
|
||||||
apfFilter.pretendPacketReceived(packet.array());
|
apfFilter.pretendPacketReceived(packet.array());
|
||||||
ipManagerCallback.assertNoProgramUpdate();
|
ipClientCallback.assertNoProgramUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApfFilterRa() throws Exception {
|
public void testApfFilterRa() throws Exception {
|
||||||
MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
|
MockIpClientCallback ipClientCallback = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
config.multicastFilter = DROP_MULTICAST;
|
config.multicastFilter = DROP_MULTICAST;
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipManagerCallback, mLog);
|
TestApfFilter apfFilter = new TestApfFilter(mContext, config, ipClientCallback, mLog);
|
||||||
byte[] program = ipManagerCallback.getApfProgram();
|
byte[] program = ipClientCallback.getApfProgram();
|
||||||
|
|
||||||
final int ROUTER_LIFETIME = 1000;
|
final int ROUTER_LIFETIME = 1000;
|
||||||
final int PREFIX_VALID_LIFETIME = 200;
|
final int PREFIX_VALID_LIFETIME = 200;
|
||||||
@@ -1268,7 +1268,7 @@ public class ApfTest {
|
|||||||
basePacket.put(IPV6_ALL_NODES_ADDRESS);
|
basePacket.put(IPV6_ALL_NODES_ADDRESS);
|
||||||
assertPass(program, basePacket.array());
|
assertPass(program, basePacket.array());
|
||||||
|
|
||||||
verifyRaLifetime(apfFilter, ipManagerCallback, basePacket, ROUTER_LIFETIME);
|
verifyRaLifetime(apfFilter, ipClientCallback, basePacket, ROUTER_LIFETIME);
|
||||||
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, -1, -1, -1));
|
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, -1, -1, -1));
|
||||||
|
|
||||||
ByteBuffer newFlowLabelPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET]);
|
ByteBuffer newFlowLabelPacket = ByteBuffer.wrap(new byte[ICMP6_RA_OPTION_OFFSET]);
|
||||||
@@ -1286,7 +1286,7 @@ public class ApfTest {
|
|||||||
zeroLengthOptionPacket.put(basePacket);
|
zeroLengthOptionPacket.put(basePacket);
|
||||||
zeroLengthOptionPacket.put((byte)ICMP6_PREFIX_OPTION_TYPE);
|
zeroLengthOptionPacket.put((byte)ICMP6_PREFIX_OPTION_TYPE);
|
||||||
zeroLengthOptionPacket.put((byte)0);
|
zeroLengthOptionPacket.put((byte)0);
|
||||||
assertInvalidRa(apfFilter, ipManagerCallback, zeroLengthOptionPacket);
|
assertInvalidRa(apfFilter, ipClientCallback, zeroLengthOptionPacket);
|
||||||
|
|
||||||
// Generate several RAs with different options and lifetimes, and verify when
|
// Generate several RAs with different options and lifetimes, and verify when
|
||||||
// ApfFilter is shown these packets, it generates programs to filter them for the
|
// ApfFilter is shown these packets, it generates programs to filter them for the
|
||||||
@@ -1304,7 +1304,7 @@ public class ApfTest {
|
|||||||
ICMP6_RA_OPTION_OFFSET + ICMP6_PREFIX_OPTION_VALID_LIFETIME_OFFSET,
|
ICMP6_RA_OPTION_OFFSET + ICMP6_PREFIX_OPTION_VALID_LIFETIME_OFFSET,
|
||||||
PREFIX_VALID_LIFETIME);
|
PREFIX_VALID_LIFETIME);
|
||||||
verifyRaLifetime(
|
verifyRaLifetime(
|
||||||
apfFilter, ipManagerCallback, prefixOptionPacket, PREFIX_PREFERRED_LIFETIME);
|
apfFilter, ipClientCallback, prefixOptionPacket, PREFIX_PREFERRED_LIFETIME);
|
||||||
verifyRaEvent(new RaEvent(
|
verifyRaEvent(new RaEvent(
|
||||||
ROUTER_LIFETIME, PREFIX_VALID_LIFETIME, PREFIX_PREFERRED_LIFETIME, -1, -1, -1));
|
ROUTER_LIFETIME, PREFIX_VALID_LIFETIME, PREFIX_PREFERRED_LIFETIME, -1, -1, -1));
|
||||||
|
|
||||||
@@ -1316,7 +1316,7 @@ public class ApfTest {
|
|||||||
rdnssOptionPacket.put((byte)(ICMP6_4_BYTE_OPTION_LEN / 8));
|
rdnssOptionPacket.put((byte)(ICMP6_4_BYTE_OPTION_LEN / 8));
|
||||||
rdnssOptionPacket.putInt(
|
rdnssOptionPacket.putInt(
|
||||||
ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, RDNSS_LIFETIME);
|
ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, RDNSS_LIFETIME);
|
||||||
verifyRaLifetime(apfFilter, ipManagerCallback, rdnssOptionPacket, RDNSS_LIFETIME);
|
verifyRaLifetime(apfFilter, ipClientCallback, rdnssOptionPacket, RDNSS_LIFETIME);
|
||||||
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, -1, RDNSS_LIFETIME, -1));
|
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, -1, RDNSS_LIFETIME, -1));
|
||||||
|
|
||||||
ByteBuffer routeInfoOptionPacket = ByteBuffer.wrap(
|
ByteBuffer routeInfoOptionPacket = ByteBuffer.wrap(
|
||||||
@@ -1327,7 +1327,7 @@ public class ApfTest {
|
|||||||
routeInfoOptionPacket.put((byte)(ICMP6_4_BYTE_OPTION_LEN / 8));
|
routeInfoOptionPacket.put((byte)(ICMP6_4_BYTE_OPTION_LEN / 8));
|
||||||
routeInfoOptionPacket.putInt(
|
routeInfoOptionPacket.putInt(
|
||||||
ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, ROUTE_LIFETIME);
|
ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, ROUTE_LIFETIME);
|
||||||
verifyRaLifetime(apfFilter, ipManagerCallback, routeInfoOptionPacket, ROUTE_LIFETIME);
|
verifyRaLifetime(apfFilter, ipClientCallback, routeInfoOptionPacket, ROUTE_LIFETIME);
|
||||||
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, ROUTE_LIFETIME, -1, -1));
|
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, ROUTE_LIFETIME, -1, -1));
|
||||||
|
|
||||||
ByteBuffer dnsslOptionPacket = ByteBuffer.wrap(
|
ByteBuffer dnsslOptionPacket = ByteBuffer.wrap(
|
||||||
@@ -1338,11 +1338,11 @@ public class ApfTest {
|
|||||||
dnsslOptionPacket.put((byte)(ICMP6_4_BYTE_OPTION_LEN / 8));
|
dnsslOptionPacket.put((byte)(ICMP6_4_BYTE_OPTION_LEN / 8));
|
||||||
dnsslOptionPacket.putInt(
|
dnsslOptionPacket.putInt(
|
||||||
ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, DNSSL_LIFETIME);
|
ICMP6_RA_OPTION_OFFSET + ICMP6_4_BYTE_LIFETIME_OFFSET, DNSSL_LIFETIME);
|
||||||
verifyRaLifetime(apfFilter, ipManagerCallback, dnsslOptionPacket, ROUTER_LIFETIME);
|
verifyRaLifetime(apfFilter, ipClientCallback, dnsslOptionPacket, ROUTER_LIFETIME);
|
||||||
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, -1, -1, DNSSL_LIFETIME));
|
verifyRaEvent(new RaEvent(ROUTER_LIFETIME, -1, -1, -1, -1, DNSSL_LIFETIME));
|
||||||
|
|
||||||
// Verify that current program filters all five RAs:
|
// Verify that current program filters all five RAs:
|
||||||
program = ipManagerCallback.getApfProgram();
|
program = ipClientCallback.getApfProgram();
|
||||||
verifyRaLifetime(program, basePacket, ROUTER_LIFETIME);
|
verifyRaLifetime(program, basePacket, ROUTER_LIFETIME);
|
||||||
verifyRaLifetime(program, newFlowLabelPacket, ROUTER_LIFETIME);
|
verifyRaLifetime(program, newFlowLabelPacket, ROUTER_LIFETIME);
|
||||||
verifyRaLifetime(program, prefixOptionPacket, PREFIX_PREFERRED_LIFETIME);
|
verifyRaLifetime(program, prefixOptionPacket, PREFIX_PREFERRED_LIFETIME);
|
||||||
@@ -1384,7 +1384,7 @@ public class ApfTest {
|
|||||||
public void testRaParsing() throws Exception {
|
public void testRaParsing() throws Exception {
|
||||||
final int maxRandomPacketSize = 512;
|
final int maxRandomPacketSize = 512;
|
||||||
final Random r = new Random();
|
final Random r = new Random();
|
||||||
MockIpManagerCallback cb = new MockIpManagerCallback();
|
MockIpClientCallback cb = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
config.multicastFilter = DROP_MULTICAST;
|
config.multicastFilter = DROP_MULTICAST;
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
@@ -1405,7 +1405,7 @@ public class ApfTest {
|
|||||||
public void testRaProcessing() throws Exception {
|
public void testRaProcessing() throws Exception {
|
||||||
final int maxRandomPacketSize = 512;
|
final int maxRandomPacketSize = 512;
|
||||||
final Random r = new Random();
|
final Random r = new Random();
|
||||||
MockIpManagerCallback cb = new MockIpManagerCallback();
|
MockIpClientCallback cb = new MockIpClientCallback();
|
||||||
ApfConfiguration config = getDefaultConfig();
|
ApfConfiguration config = getDefaultConfig();
|
||||||
config.multicastFilter = DROP_MULTICAST;
|
config.multicastFilter = DROP_MULTICAST;
|
||||||
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
config.ieee802_3Filter = DROP_802_3_FRAMES;
|
||||||
|
|||||||
Reference in New Issue
Block a user