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

Commit c4059ccd authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7124398 from 12c58554 to mainline-wifi-release

Change-Id: I82649a3ae189979afad4a1e420cbdd9f094fa667
parents f69d3952 12c58554
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -111,6 +111,21 @@ public class ConntrackMonitor extends NetlinkMonitor {
            return Objects.hash(msgType, tupleOrig, tupleReply, status, timeoutSec);
        }

        @Override
        public String toString() {
            return "ConntrackEvent{"
                    + "msg_type{"
                    + NetlinkConstants.stringForNlMsgType(msgType, OsConstants.NETLINK_NETFILTER)
                    + "}, "
                    + "tuple_orig{" + tupleOrig + "}, "
                    + "tuple_reply{" + tupleReply + "}, "
                    + "status{"
                    + status + "(" + ConntrackMessage.stringForIpConntrackStatus(status) + ")"
                    + "}, "
                    + "timeout_sec{" + Integer.toUnsignedLong(timeoutSec) + "}"
                    + "}";
        }

        /**
         * Check the established NAT session conntrack message.
         *
+46 −6
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.net.ScanResultInfoParcelable;
import android.net.StaticIpConfiguration;
import android.net.apf.ApfCapabilities;
import android.net.ip.IIpClient;
import android.net.networkstack.aidl.dhcp.DhcpOption;
import android.util.Log;

import java.nio.BufferUnderflowException;
@@ -226,6 +227,17 @@ public class ProvisioningConfiguration {
            return this;
        }

        /**
         * Specify the customized DHCP options to be put in the PRL or in the DHCP packet. Options
         * with null value will be put in the PRL.
         *
         * @param: options customized DHCP option stable parcelable list.
         */
        public Builder withDhcpOptions(List<DhcpOption> options) {
            mConfig.mDhcpOptions = options;
            return this;
        }

        /**
         * Build the configuration using previously specified parameters.
         */
@@ -430,6 +442,7 @@ public class ProvisioningConfiguration {
    public String mDisplayName = null;
    public ScanResultInfo mScanResultInfo;
    public Layer2Information mLayer2Info;
    public List<DhcpOption> mDhcpOptions;

    public ProvisioningConfiguration() {} // used by Builder

@@ -451,6 +464,7 @@ public class ProvisioningConfiguration {
        mDisplayName = other.mDisplayName;
        mScanResultInfo = other.mScanResultInfo;
        mLayer2Info = other.mLayer2Info;
        mDhcpOptions = other.mDhcpOptions;
    }

    /**
@@ -464,8 +478,8 @@ public class ProvisioningConfiguration {
        p.usingMultinetworkPolicyTracker = mUsingMultinetworkPolicyTracker;
        p.usingIpReachabilityMonitor = mUsingIpReachabilityMonitor;
        p.requestedPreDhcpActionMs = mRequestedPreDhcpActionMs;
        p.initialConfig = mInitialConfig == null ? null : mInitialConfig.toStableParcelable();
        p.staticIpConfig = mStaticIpConfig == null
        p.initialConfig = (mInitialConfig == null) ? null : mInitialConfig.toStableParcelable();
        p.staticIpConfig = (mStaticIpConfig == null)
                ? null
                : new StaticIpConfiguration(mStaticIpConfig);
        p.apfCapabilities = mApfCapabilities; // ApfCapabilities is immutable
@@ -473,8 +487,9 @@ public class ProvisioningConfiguration {
        p.ipv6AddrGenMode = mIPv6AddrGenMode;
        p.network = mNetwork;
        p.displayName = mDisplayName;
        p.scanResultInfo = mScanResultInfo == null ? null : mScanResultInfo.toStableParcelable();
        p.layer2Info = mLayer2Info == null ? null : mLayer2Info.toStableParcelable();
        p.scanResultInfo = (mScanResultInfo == null) ? null : mScanResultInfo.toStableParcelable();
        p.layer2Info = (mLayer2Info == null) ? null : mLayer2Info.toStableParcelable();
        p.options = (mDhcpOptions == null) ? null : new ArrayList<>(mDhcpOptions);
        return p;
    }

@@ -492,7 +507,7 @@ public class ProvisioningConfiguration {
        config.mUsingIpReachabilityMonitor = p.usingIpReachabilityMonitor;
        config.mRequestedPreDhcpActionMs = p.requestedPreDhcpActionMs;
        config.mInitialConfig = InitialConfiguration.fromStableParcelable(p.initialConfig);
        config.mStaticIpConfig = p.staticIpConfig == null
        config.mStaticIpConfig = (p.staticIpConfig == null)
                ? null
                : new StaticIpConfiguration(p.staticIpConfig);
        config.mApfCapabilities = p.apfCapabilities; // ApfCapabilities is immutable
@@ -502,6 +517,7 @@ public class ProvisioningConfiguration {
        config.mDisplayName = p.displayName;
        config.mScanResultInfo = ScanResultInfo.fromStableParcelable(p.scanResultInfo);
        config.mLayer2Info = Layer2Information.fromStableParcelable(p.layer2Info);
        config.mDhcpOptions = (p.options == null) ? null : new ArrayList<>(p.options);
        return config;
    }

@@ -523,9 +539,32 @@ public class ProvisioningConfiguration {
                .add("mDisplayName: " + mDisplayName)
                .add("mScanResultInfo: " + mScanResultInfo)
                .add("mLayer2Info: " + mLayer2Info)
                .add("mDhcpOptions: " + mDhcpOptions)
                .toString();
    }

    // TODO: mark DhcpOption stable parcelable with @JavaDerive(equals=true, toString=true)
    // and @JavaOnlyImmutable.
    private static boolean dhcpOptionEquals(@Nullable DhcpOption obj1, @Nullable DhcpOption obj2) {
        if (obj1 == obj2) return true;
        if (obj1 == null || obj2 == null) return false;
        return obj1.type == obj2.type && Arrays.equals(obj1.value, obj2.value);
    }

    // TODO: use Objects.equals(List<DhcpOption>, List<DhcpOption>) method instead once
    // auto-generated equals() method of stable parcelable is supported in mainline-prod.
    private static boolean dhcpOptionListEquals(@Nullable List<DhcpOption> l1,
            @Nullable List<DhcpOption> l2) {
        if (l1 == l2) return true;
        if (l1 == null || l2 == null) return false;
        if (l1.size() != l2.size()) return false;

        for (int i = 0; i < l1.size(); i++) {
            if (!dhcpOptionEquals(l1.get(i), l2.get(i))) return false;
        }
        return true;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof ProvisioningConfiguration)) return false;
@@ -544,7 +583,8 @@ public class ProvisioningConfiguration {
                && Objects.equals(mNetwork, other.mNetwork)
                && Objects.equals(mDisplayName, other.mDisplayName)
                && Objects.equals(mScanResultInfo, other.mScanResultInfo)
                && Objects.equals(mLayer2Info, other.mLayer2Info);
                && Objects.equals(mLayer2Info, other.mLayer2Info)
                && dhcpOptionListEquals(mDhcpOptions, other.mDhcpOptions);
    }

    public boolean isValid() {
+99 −0
Original line number Diff line number Diff line
@@ -134,6 +134,19 @@ public class ConntrackMessage extends NetlinkMessage {
        public int hashCode() {
            return Objects.hash(srcIp, dstIp, srcPort, dstPort, protoNum);
        }

        @Override
        public String toString() {
            final String srcIpStr = (srcIp == null) ? "null" : srcIp.getHostAddress();
            final String dstIpStr = (dstIp == null) ? "null" : dstIp.getHostAddress();
            final String protoStr = NetlinkConstants.stringForProtocol(protoNum);

            return "Tuple{"
                    + protoStr + ": "
                    + srcIpStr + ":" + Short.toUnsignedInt(srcPort) + " -> "
                    + dstIpStr + ":" + Short.toUnsignedInt(dstPort)
                    + "}";
        }
    }

    /**
@@ -450,4 +463,90 @@ public class ConntrackMessage extends NetlinkMessage {
    public short getMessageType() {
        return (short) (getHeader().nlmsg_type & ~(NetlinkConstants.NFNL_SUBSYS_CTNETLINK << 8));
    }

    /**
     * Convert an ip conntrack status to a string.
     */
    public static String stringForIpConntrackStatus(int flags) {
        final StringBuilder sb = new StringBuilder();

        if ((flags & IPS_EXPECTED) != 0) {
            sb.append("IPS_EXPECTED");
        }
        if ((flags & IPS_SEEN_REPLY) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_SEEN_REPLY");
        }
        if ((flags & IPS_ASSURED) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_ASSURED");
        }
        if ((flags & IPS_CONFIRMED) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_CONFIRMED");
        }
        if ((flags & IPS_SRC_NAT) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_SRC_NAT");
        }
        if ((flags & IPS_DST_NAT) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_DST_NAT");
        }
        if ((flags & IPS_SEQ_ADJUST) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_SEQ_ADJUST");
        }
        if ((flags & IPS_SRC_NAT_DONE) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_SRC_NAT_DONE");
        }
        if ((flags & IPS_DST_NAT_DONE) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_DST_NAT_DONE");
        }
        if ((flags & IPS_DYING) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_DYING");
        }
        if ((flags & IPS_FIXED_TIMEOUT) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_FIXED_TIMEOUT");
        }
        if ((flags & IPS_TEMPLATE) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_TEMPLATE");
        }
        if ((flags & IPS_UNTRACKED) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_UNTRACKED");
        }
        if ((flags & IPS_HELPER) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_HELPER");
        }
        if ((flags & IPS_OFFLOAD) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_OFFLOAD");
        }
        if ((flags & IPS_HW_OFFLOAD) != 0) {
            if (sb.length() > 0) sb.append("|");
            sb.append("IPS_HW_OFFLOAD");
        }
        return sb.toString();
    }

    @Override
    public String toString() {
        return "ConntrackMessage{"
                + "nlmsghdr{"
                + (mHeader == null ? "" : mHeader.toString(OsConstants.NETLINK_NETFILTER))
                + "}, "
                + "nfgenmsg{" + nfGenMsg + "}, "
                + "tuple_orig{" + tupleOrig + "}, "
                + "tuple_reply{" + tupleReply + "}, "
                + "status{" + status + "(" + stringForIpConntrackStatus(status) + ")" + "}, "
                + "timeout_sec{" + Integer.toUnsignedLong(timeoutSec) + "}"
                + "}";
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -89,4 +89,15 @@ public class StructNfGenMsg {
    private static boolean hasAvailableSpace(@NonNull ByteBuffer byteBuffer) {
        return byteBuffer.remaining() >= STRUCT_SIZE;
    }

    @Override
    public String toString() {
        final String familyStr = NetlinkConstants.stringForAddressFamily(nfgen_family);

        return "NfGenMsg{ "
                + "nfgen_family{" + familyStr + "}, "
                + "version{" + Byte.toUnsignedInt(version) + "}, "
                + "res_id{" + Short.toUnsignedInt(res_id) + "} "
                + "}";
    }
}
+6 −1
Original line number Diff line number Diff line
@@ -65,7 +65,10 @@ aidl_interface {
    name: "networkstack-aidl-interfaces",
    local_include_dir: "src",
    include_dirs: [
        "frameworks/base/core/java", // For framework parcelables.
        // For framework parcelables.
        "frameworks/base/core/java",
        // For API parcelables in connectivity
        "frameworks/base/packages/Connectivity/framework/src",
        "frameworks/native/aidl/binder", // For PersistableBundle.aidl
    ],
    srcs: [
@@ -94,6 +97,7 @@ aidl_interface {
        "src/android/net/ip/IIpClientCallbacks.aidl",
        // New AIDL classes should go into android.net.networkstack.aidl so they can be clearly
        // identified
        "src/android/net/networkstack/aidl/dhcp/DhcpOption.aidl",
    ],
    backend: {
        java: {
@@ -124,6 +128,7 @@ aidl_interface {
        "7",
        "8",
        "9",
        "10",
    ],
    // TODO: have tethering depend on networkstack-client and set visibility to private
    visibility: [
Loading