Loading services/net/java/android/net/apf/ApfCapabilities.java +10 −0 Original line number Diff line number Diff line Loading @@ -49,4 +49,14 @@ public class ApfCapabilities { return String.format("%s{version: %d, maxSize: %d, format: %d}", getClass().getSimpleName(), apfVersionSupported, maximumApfProgramSize, apfPacketFormat); } /** * Returns true if the APF interpreter advertises support for the data buffer access opcodes * LDDW and STDW. * * Full LDDW and STDW support is present from APFv4 on. */ public boolean hasDataAccess() { return apfVersionSupported >= 4; } } services/net/java/android/net/apf/ApfFilter.java +247 −29 File changed.Preview size limit exceeded, changes collapsed. Show changes services/net/java/android/net/apf/ApfGenerator.java +2 −3 Original line number Diff line number Diff line Loading @@ -378,8 +378,7 @@ public class ApfGenerator { } /** * Returns true if the specified {@code version} is supported by the ApfGenerator, otherwise * false. * Returns true if the ApfGenerator supports the specified {@code version}, otherwise false. */ public static boolean supportsVersion(int version) { return version >= MIN_APF_VERSION; Loading Loading @@ -753,7 +752,7 @@ public class ApfGenerator { /** * Add an instruction to the end of the program to jump to {@code target} if the bytes of the * packet at, an offset specified by {@code register}, match {@code bytes}. * packet at an offset specified by {@code register} match {@code bytes}. */ public ApfGenerator addJumpIfBytesNotEqual(Register register, byte[] bytes, String target) throws IllegalInstructionException { Loading services/net/java/android/net/ip/IpClient.java +21 −12 Original line number Diff line number Diff line Loading @@ -624,7 +624,14 @@ public class IpClient extends StateMachine { private ApfFilter mApfFilter; private boolean mMulticastFiltering; private long mStartTimeMillis; private byte[] mApfDataSnapshot; /** * Reading the snapshot is an asynchronous operation initiated by invoking * Callback.startReadPacketFilter() and completed when the WiFi Service responds with an * EVENT_READ_PACKET_FILTER_COMPLETE message. The mApfDataSnapshotComplete condition variable * signals when a new snapshot is ready. */ private final ConditionVariable mApfDataSnapshotComplete = new ConditionVariable(); public static class Dependencies { public INetworkManagementService getNMS() { Loading Loading @@ -881,13 +888,21 @@ public class IpClient extends StateMachine { final ProvisioningConfiguration provisioningConfig = mConfiguration; final ApfCapabilities apfCapabilities = (provisioningConfig != null) ? provisioningConfig.mApfCapabilities : null; final byte[] apfDataSnapshot = mApfDataSnapshot; IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); pw.println(mTag + " APF dump:"); pw.increaseIndent(); if (apfFilter != null) { if (apfCapabilities.hasDataAccess()) { // Request a new snapshot, then wait for it. mApfDataSnapshotComplete.close(); mCallback.startReadPacketFilter(); if (!mApfDataSnapshotComplete.block(1000)) { pw.print("TIMEOUT: DUMPING STALE APF SNAPSHOT"); } } apfFilter.dump(pw); } else { pw.print("No active ApfFilter; "); if (provisioningConfig == null) { Loading @@ -899,15 +914,6 @@ public class IpClient extends StateMachine { } } pw.decreaseIndent(); pw.println(mTag + " latest APF data snapshot: "); pw.increaseIndent(); if (apfDataSnapshot != null) { pw.println(HexDump.dumpHexString(apfDataSnapshot)); } else { pw.println("No last snapshot."); } pw.decreaseIndent(); pw.println(); pw.println(mTag + " current ProvisioningConfiguration:"); pw.increaseIndent(); Loading Loading @@ -1704,7 +1710,10 @@ public class IpClient extends StateMachine { } case EVENT_READ_PACKET_FILTER_COMPLETE: { mApfDataSnapshot = (byte[]) msg.obj; if (mApfFilter != null) { mApfFilter.setDataSnapshot((byte[]) msg.obj); } mApfDataSnapshotComplete.open(); break; } Loading Loading
services/net/java/android/net/apf/ApfCapabilities.java +10 −0 Original line number Diff line number Diff line Loading @@ -49,4 +49,14 @@ public class ApfCapabilities { return String.format("%s{version: %d, maxSize: %d, format: %d}", getClass().getSimpleName(), apfVersionSupported, maximumApfProgramSize, apfPacketFormat); } /** * Returns true if the APF interpreter advertises support for the data buffer access opcodes * LDDW and STDW. * * Full LDDW and STDW support is present from APFv4 on. */ public boolean hasDataAccess() { return apfVersionSupported >= 4; } }
services/net/java/android/net/apf/ApfFilter.java +247 −29 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/net/java/android/net/apf/ApfGenerator.java +2 −3 Original line number Diff line number Diff line Loading @@ -378,8 +378,7 @@ public class ApfGenerator { } /** * Returns true if the specified {@code version} is supported by the ApfGenerator, otherwise * false. * Returns true if the ApfGenerator supports the specified {@code version}, otherwise false. */ public static boolean supportsVersion(int version) { return version >= MIN_APF_VERSION; Loading Loading @@ -753,7 +752,7 @@ public class ApfGenerator { /** * Add an instruction to the end of the program to jump to {@code target} if the bytes of the * packet at, an offset specified by {@code register}, match {@code bytes}. * packet at an offset specified by {@code register} match {@code bytes}. */ public ApfGenerator addJumpIfBytesNotEqual(Register register, byte[] bytes, String target) throws IllegalInstructionException { Loading
services/net/java/android/net/ip/IpClient.java +21 −12 Original line number Diff line number Diff line Loading @@ -624,7 +624,14 @@ public class IpClient extends StateMachine { private ApfFilter mApfFilter; private boolean mMulticastFiltering; private long mStartTimeMillis; private byte[] mApfDataSnapshot; /** * Reading the snapshot is an asynchronous operation initiated by invoking * Callback.startReadPacketFilter() and completed when the WiFi Service responds with an * EVENT_READ_PACKET_FILTER_COMPLETE message. The mApfDataSnapshotComplete condition variable * signals when a new snapshot is ready. */ private final ConditionVariable mApfDataSnapshotComplete = new ConditionVariable(); public static class Dependencies { public INetworkManagementService getNMS() { Loading Loading @@ -881,13 +888,21 @@ public class IpClient extends StateMachine { final ProvisioningConfiguration provisioningConfig = mConfiguration; final ApfCapabilities apfCapabilities = (provisioningConfig != null) ? provisioningConfig.mApfCapabilities : null; final byte[] apfDataSnapshot = mApfDataSnapshot; IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); pw.println(mTag + " APF dump:"); pw.increaseIndent(); if (apfFilter != null) { if (apfCapabilities.hasDataAccess()) { // Request a new snapshot, then wait for it. mApfDataSnapshotComplete.close(); mCallback.startReadPacketFilter(); if (!mApfDataSnapshotComplete.block(1000)) { pw.print("TIMEOUT: DUMPING STALE APF SNAPSHOT"); } } apfFilter.dump(pw); } else { pw.print("No active ApfFilter; "); if (provisioningConfig == null) { Loading @@ -899,15 +914,6 @@ public class IpClient extends StateMachine { } } pw.decreaseIndent(); pw.println(mTag + " latest APF data snapshot: "); pw.increaseIndent(); if (apfDataSnapshot != null) { pw.println(HexDump.dumpHexString(apfDataSnapshot)); } else { pw.println("No last snapshot."); } pw.decreaseIndent(); pw.println(); pw.println(mTag + " current ProvisioningConfiguration:"); pw.increaseIndent(); Loading Loading @@ -1704,7 +1710,10 @@ public class IpClient extends StateMachine { } case EVENT_READ_PACKET_FILTER_COMPLETE: { mApfDataSnapshot = (byte[]) msg.obj; if (mApfFilter != null) { mApfFilter.setDataSnapshot((byte[]) msg.obj); } mApfDataSnapshotComplete.open(); break; } Loading