Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ec073b7 authored by Bernie Innocenti's avatar Bernie Innocenti Committed by android-build-merger
Browse files

Merge "apf: Add counters for dropped / passed packets" into pi-dev

am: d11d7ff8

Change-Id: Iaec1efa4e827eac986049ddbb440e2a4824a673b
parents 58030441 d11d7ff8
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+247 −29

File changed.

Preview size limit exceeded, changes collapsed.

+2 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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 {
+21 −12
Original line number Diff line number Diff line
@@ -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() {
@@ -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) {
@@ -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();
@@ -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;
                }