Loading services/net/java/android/net/NattKeepalivePacketData.java→core/java/android/net/NattKeepalivePacketData.java +36 −13 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -19,9 +19,9 @@ package android.net; import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS; import static android.net.SocketKeepalive.ERROR_INVALID_PORT; import android.annotation.NonNull; import android.net.SocketKeepalive.InvalidPacketException; import android.net.util.IpUtils; import android.os.Parcel; import android.os.Parcelable; import android.system.OsConstants; Loading Loading @@ -79,17 +79,40 @@ public final class NattKeepalivePacketData extends KeepalivePacketData implement return new NattKeepalivePacketData(srcAddress, srcPort, dstAddress, dstPort, buf.array()); } /** * Convert this NattKeepalivePacketData to a NattKeepalivePacketDataParcelable. */ @NonNull public NattKeepalivePacketDataParcelable toStableParcelable() { final NattKeepalivePacketDataParcelable parcel = new NattKeepalivePacketDataParcelable(); /** Parcelable Implementation */ public int describeContents() { return 0; } /** Write to parcel */ public void writeToParcel(Parcel out, int flags) { out.writeString(srcAddress.getHostAddress()); out.writeString(dstAddress.getHostAddress()); out.writeInt(srcPort); out.writeInt(dstPort); } /** Parcelable Creator */ public static final Parcelable.Creator<NattKeepalivePacketData> CREATOR = new Parcelable.Creator<NattKeepalivePacketData>() { public NattKeepalivePacketData createFromParcel(Parcel in) { final InetAddress srcAddress = InetAddresses.parseNumericAddress(in.readString()); final InetAddress dstAddress = InetAddresses.parseNumericAddress(in.readString()); final int srcPort = in.readInt(); final int dstPort = in.readInt(); try { return NattKeepalivePacketData.nattKeepalivePacket(srcAddress, srcPort, dstAddress, dstPort); } catch (InvalidPacketException e) { throw new IllegalArgumentException( "Invalid NAT-T keepalive data: " + e.error); } } parcel.srcAddress = srcAddress.getAddress(); parcel.srcPort = srcPort; parcel.dstAddress = dstAddress.getAddress(); parcel.dstPort = dstPort; return parcel; public NattKeepalivePacketData[] newArray(int size) { return new NattKeepalivePacketData[size]; } }; } core/java/android/net/NetworkAgent.java +0 −2 Original line number Diff line number Diff line Loading @@ -511,7 +511,6 @@ public abstract class NetworkAgent extends Handler { * override this method. */ protected void addKeepalivePacketFilter(Message msg) { onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** Loading @@ -520,7 +519,6 @@ public abstract class NetworkAgent extends Handler { * must override this method. */ protected void removeKeepalivePacketFilter(Message msg) { onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** Loading services/core/java/com/android/server/connectivity/KeepaliveTracker.java +1 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,7 @@ public class KeepaliveTracker { public String toString() { return "KeepaliveInfo [" + " type=" + mType + " network=" + mNai.network + " startedState=" + startedStateString(mStartedState) + " " Loading services/net/java/android/net/ip/IpClientManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.net.NattKeepalivePacketData; import android.net.ProxyInfo; import android.net.TcpKeepalivePacketData; import android.net.shared.ProvisioningConfiguration; import android.net.util.KeepalivePacketDataUtil; import android.os.Binder; import android.os.RemoteException; import android.util.Log; Loading Loading @@ -229,7 +230,8 @@ public class IpClientManager { public boolean addKeepalivePacketFilter(int slot, NattKeepalivePacketData pkt) { final long token = Binder.clearCallingIdentity(); try { mIpClient.addNattKeepalivePacketFilter(slot, pkt.toStableParcelable()); mIpClient.addNattKeepalivePacketFilter( slot, KeepalivePacketDataUtil.toStableParcelable(pkt)); return true; } catch (RemoteException e) { log("Error adding Keepalive Packet Filter ", e); Loading services/net/java/android/net/util/KeepalivePacketDataUtil.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.util; import android.annotation.NonNull; import android.net.NattKeepalivePacketData; import android.net.NattKeepalivePacketDataParcelable; /** @hide */ public final class KeepalivePacketDataUtil { /** * Convert this NattKeepalivePacketData to a NattKeepalivePacketDataParcelable. */ @NonNull public static NattKeepalivePacketDataParcelable toStableParcelable( NattKeepalivePacketData pkt) { final NattKeepalivePacketDataParcelable parcel = new NattKeepalivePacketDataParcelable(); parcel.srcAddress = pkt.srcAddress.getAddress(); parcel.srcPort = pkt.srcPort; parcel.dstAddress = pkt.dstAddress.getAddress(); parcel.dstPort = pkt.dstPort; return parcel; } } Loading
services/net/java/android/net/NattKeepalivePacketData.java→core/java/android/net/NattKeepalivePacketData.java +36 −13 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -19,9 +19,9 @@ package android.net; import static android.net.SocketKeepalive.ERROR_INVALID_IP_ADDRESS; import static android.net.SocketKeepalive.ERROR_INVALID_PORT; import android.annotation.NonNull; import android.net.SocketKeepalive.InvalidPacketException; import android.net.util.IpUtils; import android.os.Parcel; import android.os.Parcelable; import android.system.OsConstants; Loading Loading @@ -79,17 +79,40 @@ public final class NattKeepalivePacketData extends KeepalivePacketData implement return new NattKeepalivePacketData(srcAddress, srcPort, dstAddress, dstPort, buf.array()); } /** * Convert this NattKeepalivePacketData to a NattKeepalivePacketDataParcelable. */ @NonNull public NattKeepalivePacketDataParcelable toStableParcelable() { final NattKeepalivePacketDataParcelable parcel = new NattKeepalivePacketDataParcelable(); /** Parcelable Implementation */ public int describeContents() { return 0; } /** Write to parcel */ public void writeToParcel(Parcel out, int flags) { out.writeString(srcAddress.getHostAddress()); out.writeString(dstAddress.getHostAddress()); out.writeInt(srcPort); out.writeInt(dstPort); } /** Parcelable Creator */ public static final Parcelable.Creator<NattKeepalivePacketData> CREATOR = new Parcelable.Creator<NattKeepalivePacketData>() { public NattKeepalivePacketData createFromParcel(Parcel in) { final InetAddress srcAddress = InetAddresses.parseNumericAddress(in.readString()); final InetAddress dstAddress = InetAddresses.parseNumericAddress(in.readString()); final int srcPort = in.readInt(); final int dstPort = in.readInt(); try { return NattKeepalivePacketData.nattKeepalivePacket(srcAddress, srcPort, dstAddress, dstPort); } catch (InvalidPacketException e) { throw new IllegalArgumentException( "Invalid NAT-T keepalive data: " + e.error); } } parcel.srcAddress = srcAddress.getAddress(); parcel.srcPort = srcPort; parcel.dstAddress = dstAddress.getAddress(); parcel.dstPort = dstPort; return parcel; public NattKeepalivePacketData[] newArray(int size) { return new NattKeepalivePacketData[size]; } }; }
core/java/android/net/NetworkAgent.java +0 −2 Original line number Diff line number Diff line Loading @@ -511,7 +511,6 @@ public abstract class NetworkAgent extends Handler { * override this method. */ protected void addKeepalivePacketFilter(Message msg) { onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** Loading @@ -520,7 +519,6 @@ public abstract class NetworkAgent extends Handler { * must override this method. */ protected void removeKeepalivePacketFilter(Message msg) { onSocketKeepaliveEvent(msg.arg1, SocketKeepalive.ERROR_UNSUPPORTED); } /** Loading
services/core/java/com/android/server/connectivity/KeepaliveTracker.java +1 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,7 @@ public class KeepaliveTracker { public String toString() { return "KeepaliveInfo [" + " type=" + mType + " network=" + mNai.network + " startedState=" + startedStateString(mStartedState) + " " Loading
services/net/java/android/net/ip/IpClientManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.net.NattKeepalivePacketData; import android.net.ProxyInfo; import android.net.TcpKeepalivePacketData; import android.net.shared.ProvisioningConfiguration; import android.net.util.KeepalivePacketDataUtil; import android.os.Binder; import android.os.RemoteException; import android.util.Log; Loading Loading @@ -229,7 +230,8 @@ public class IpClientManager { public boolean addKeepalivePacketFilter(int slot, NattKeepalivePacketData pkt) { final long token = Binder.clearCallingIdentity(); try { mIpClient.addNattKeepalivePacketFilter(slot, pkt.toStableParcelable()); mIpClient.addNattKeepalivePacketFilter( slot, KeepalivePacketDataUtil.toStableParcelable(pkt)); return true; } catch (RemoteException e) { log("Error adding Keepalive Packet Filter ", e); Loading
services/net/java/android/net/util/KeepalivePacketDataUtil.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.util; import android.annotation.NonNull; import android.net.NattKeepalivePacketData; import android.net.NattKeepalivePacketDataParcelable; /** @hide */ public final class KeepalivePacketDataUtil { /** * Convert this NattKeepalivePacketData to a NattKeepalivePacketDataParcelable. */ @NonNull public static NattKeepalivePacketDataParcelable toStableParcelable( NattKeepalivePacketData pkt) { final NattKeepalivePacketDataParcelable parcel = new NattKeepalivePacketDataParcelable(); parcel.srcAddress = pkt.srcAddress.getAddress(); parcel.srcPort = pkt.srcPort; parcel.dstAddress = pkt.dstAddress.getAddress(); parcel.dstPort = pkt.dstPort; return parcel; } }