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

Commit 0ec7b1e8 authored by Bernie Innocenti's avatar Bernie Innocenti Committed by android-build-merger
Browse files

Merge changes from topic "apf-read-ram"

am: b5dda0e3

Change-Id: I80d70e5bce6d1a0903599e98d2d251459df1292a
parents 6a8b2377 b5dda0e3
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -49,4 +49,14 @@ public class ApfCapabilities {
        return String.format("%s{version: %d, maxSize: %d, format: %d}", getClass().getSimpleName(),
        return String.format("%s{version: %d, maxSize: %d, format: %d}", getClass().getSimpleName(),
                apfVersionSupported, maximumApfProgramSize, apfPacketFormat);
                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 Original line 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
     * Returns true if the ApfGenerator supports the specified {@code version}, otherwise false.
     * false.
     */
     */
    public static boolean supportsVersion(int version) {
    public static boolean supportsVersion(int version) {
        return version >= MIN_APF_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
     * 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)
    public ApfGenerator addJumpIfBytesNotEqual(Register register, byte[] bytes, String target)
            throws IllegalInstructionException {
            throws IllegalInstructionException {
+42 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.net.ip;
package android.net.ip;


import com.android.internal.util.HexDump;
import com.android.internal.util.MessageUtils;
import com.android.internal.util.MessageUtils;
import com.android.internal.util.WakeupMessage;
import com.android.internal.util.WakeupMessage;


@@ -174,6 +175,12 @@ public class IpClient extends StateMachine {
        // Install an APF program to filter incoming packets.
        // Install an APF program to filter incoming packets.
        public void installPacketFilter(byte[] filter) {}
        public void installPacketFilter(byte[] filter) {}


        // Asynchronously read back the APF program & data buffer from the wifi driver.
        // Due to Wifi HAL limitations, the current implementation only supports dumping the entire
        // buffer. In response to this request, the driver returns the data buffer asynchronously
        // by sending an IpClient#EVENT_READ_PACKET_FILTER_COMPLETE message.
        public void startReadPacketFilter() {}

        // If multicast filtering cannot be accomplished with APF, this function will be called to
        // If multicast filtering cannot be accomplished with APF, this function will be called to
        // actuate multicast filtering using another means.
        // actuate multicast filtering using another means.
        public void setFallbackMulticastFilter(boolean enabled) {}
        public void setFallbackMulticastFilter(boolean enabled) {}
@@ -280,6 +287,11 @@ public class IpClient extends StateMachine {
            log("installPacketFilter(byte[" + filter.length + "])");
            log("installPacketFilter(byte[" + filter.length + "])");
        }
        }
        @Override
        @Override
        public void startReadPacketFilter() {
            mCallback.startReadPacketFilter();
            log("startReadPacketFilter()");
        }
        @Override
        public void setFallbackMulticastFilter(boolean enabled) {
        public void setFallbackMulticastFilter(boolean enabled) {
            mCallback.setFallbackMulticastFilter(enabled);
            mCallback.setFallbackMulticastFilter(enabled);
            log("setFallbackMulticastFilter(" + enabled + ")");
            log("setFallbackMulticastFilter(" + enabled + ")");
@@ -591,6 +603,7 @@ public class IpClient extends StateMachine {
    private static final int CMD_SET_MULTICAST_FILTER             = 9;
    private static final int CMD_SET_MULTICAST_FILTER             = 9;
    private static final int EVENT_PROVISIONING_TIMEOUT           = 10;
    private static final int EVENT_PROVISIONING_TIMEOUT           = 10;
    private static final int EVENT_DHCPACTION_TIMEOUT             = 11;
    private static final int EVENT_DHCPACTION_TIMEOUT             = 11;
    private static final int EVENT_READ_PACKET_FILTER_COMPLETE    = 12;


    private static final int MAX_LOG_RECORDS = 500;
    private static final int MAX_LOG_RECORDS = 500;
    private static final int MAX_PACKET_RECORDS = 100;
    private static final int MAX_PACKET_RECORDS = 100;
@@ -644,6 +657,14 @@ public class IpClient extends StateMachine {
    private boolean mMulticastFiltering;
    private boolean mMulticastFiltering;
    private long mStartTimeMillis;
    private long mStartTimeMillis;


    /**
     * 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 static class Dependencies {
        public INetworkManagementService getNMS() {
        public INetworkManagementService getNMS() {
            return INetworkManagementService.Stub.asInterface(
            return INetworkManagementService.Stub.asInterface(
@@ -857,6 +878,10 @@ public class IpClient extends StateMachine {
        sendMessage(EVENT_PRE_DHCP_ACTION_COMPLETE);
        sendMessage(EVENT_PRE_DHCP_ACTION_COMPLETE);
    }
    }


    public void readPacketFilterComplete(byte[] data) {
        sendMessage(EVENT_READ_PACKET_FILTER_COMPLETE, data);
    }

    /**
    /**
     * Set the TCP buffer sizes to use.
     * Set the TCP buffer sizes to use.
     *
     *
@@ -902,7 +927,16 @@ public class IpClient extends StateMachine {
        pw.println(mTag + " APF dump:");
        pw.println(mTag + " APF dump:");
        pw.increaseIndent();
        pw.increaseIndent();
        if (apfFilter != null) {
        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);
            apfFilter.dump(pw);

        } else {
        } else {
            pw.print("No active ApfFilter; ");
            pw.print("No active ApfFilter; ");
            if (provisioningConfig == null) {
            if (provisioningConfig == null) {
@@ -914,7 +948,6 @@ public class IpClient extends StateMachine {
            }
            }
        }
        }
        pw.decreaseIndent();
        pw.decreaseIndent();

        pw.println();
        pw.println();
        pw.println(mTag + " current ProvisioningConfiguration:");
        pw.println(mTag + " current ProvisioningConfiguration:");
        pw.increaseIndent();
        pw.increaseIndent();
@@ -1710,6 +1743,14 @@ public class IpClient extends StateMachine {
                    break;
                    break;
                }
                }


                case EVENT_READ_PACKET_FILTER_COMPLETE: {
                    if (mApfFilter != null) {
                        mApfFilter.setDataSnapshot((byte[]) msg.obj);
                    }
                    mApfDataSnapshotComplete.open();
                    break;
                }

                case EVENT_DHCPACTION_TIMEOUT:
                case EVENT_DHCPACTION_TIMEOUT:
                    stopDhcpAction();
                    stopDhcpAction();
                    break;
                    break;