Loading packages/NetworkStack/src/android/net/apf/ApfFilter.java +15 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NattKeepalivePacketDataParcelable; import android.net.TcpKeepalivePacketDataParcelable; import android.net.apf.ApfGenerator.IllegalInstructionException; import android.net.apf.ApfGenerator.Register; Loading Loading @@ -1691,13 +1692,13 @@ public class ApfFilter { } /** * Add keepalive ack packet filter. * Add TCP keepalive ack packet filter. * This will add a filter to drop acks to the keepalive packet passed as an argument. * * @param slot The index used to access the filter. * @param sentKeepalivePacket The attributes of the sent keepalive packet. */ public synchronized void addKeepalivePacketFilter(final int slot, public synchronized void addTcpKeepalivePacketFilter(final int slot, final TcpKeepalivePacketDataParcelable sentKeepalivePacket) { log("Adding keepalive ack(" + slot + ")"); if (null != mKeepaliveAcks.get(slot)) { Loading @@ -1710,6 +1711,18 @@ public class ApfFilter { installNewProgramLocked(); } /** * Add NATT keepalive packet filter. * This will add a filter to drop NATT keepalive packet which is passed as an argument. * * @param slot The index used to access the filter. * @param sentKeepalivePacket The attributes of the sent keepalive packet. */ public synchronized void addNattKeepalivePacketFilter(final int slot, final NattKeepalivePacketDataParcelable sentKeepalivePacket) { Log.e(TAG, "APF add NATT keepalive filter is not implemented"); } /** * Remove keepalive packet filter. * Loading packages/NetworkStack/src/android/net/ip/IpClient.java +30 −4 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.net.INetd; import android.net.IpPrefix; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NattKeepalivePacketDataParcelable; import android.net.NetworkStackIpMemoryStore; import android.net.ProvisioningConfigurationParcelable; import android.net.ProxyInfo; Loading Loading @@ -371,6 +372,10 @@ public class IpClient extends StateMachine { private boolean mMulticastFiltering; private long mStartTimeMillis; /* This must match the definition in KeepaliveTracker.KeepaliveInfo */ private static final int TYPE_NATT = 1; private static final int TYPE_TCP = 2; /** * Reading the snapshot is an asynchronous operation initiated by invoking * Callback.startReadPacketFilter() and completed when the WiFi Service responds with an Loading Loading @@ -553,6 +558,11 @@ public class IpClient extends StateMachine { IpClient.this.addKeepalivePacketFilter(slot, pkt); } @Override public void addNattKeepalivePacketFilter(int slot, NattKeepalivePacketDataParcelable pkt) { checkNetworkStackCallingPermission(); IpClient.this.addNattKeepalivePacketFilter(slot, pkt); } @Override public void removeKeepalivePacketFilter(int slot) { checkNetworkStackCallingPermission(); IpClient.this.removeKeepalivePacketFilter(slot); Loading Loading @@ -691,11 +701,20 @@ public class IpClient extends StateMachine { } /** * Called by WifiStateMachine to add keepalive packet filter before setting up * Called by WifiStateMachine to add TCP keepalive packet filter before setting up * keepalive offload. */ public void addKeepalivePacketFilter(int slot, @NonNull TcpKeepalivePacketDataParcelable pkt) { sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF, slot, 0 /* Unused */, pkt); sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF, slot, TYPE_TCP, pkt); } /** * Called by WifiStateMachine to add NATT keepalive packet filter before setting up * keepalive offload. */ public void addNattKeepalivePacketFilter(int slot, @NonNull NattKeepalivePacketDataParcelable pkt) { sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF, slot, TYPE_NATT, pkt); } /** Loading Loading @@ -1607,10 +1626,17 @@ public class IpClient extends StateMachine { case CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF: { final int slot = msg.arg1; final int type = msg.arg2; if (mApfFilter != null) { mApfFilter.addKeepalivePacketFilter(slot, if (type == TYPE_NATT) { mApfFilter.addNattKeepalivePacketFilter(slot, (NattKeepalivePacketDataParcelable) msg.obj); } else { mApfFilter.addTcpKeepalivePacketFilter(slot, (TcpKeepalivePacketDataParcelable) msg.obj); } } break; } Loading packages/NetworkStack/tests/src/android/net/apf/ApfTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -1553,7 +1553,7 @@ public class ApfTest { parcel.seq = seqNum; parcel.ack = ackNum; apfFilter.addKeepalivePacketFilter(slot1, parcel); apfFilter.addTcpKeepalivePacketFilter(slot1, parcel); program = cb.getApfProgram(); // Verify IPv4 keepalive ack packet is dropped Loading Loading @@ -1592,7 +1592,7 @@ public class ApfTest { ipv6Parcel.seq = seqNum; ipv6Parcel.ack = ackNum; apfFilter.addKeepalivePacketFilter(slot1, ipv6Parcel); apfFilter.addTcpKeepalivePacketFilter(slot1, ipv6Parcel); program = cb.getApfProgram(); // Verify IPv6 keepalive ack packet is dropped Loading @@ -1614,8 +1614,8 @@ public class ApfTest { apfFilter.removeKeepalivePacketFilter(slot1); // Verify multiple filters apfFilter.addKeepalivePacketFilter(slot1, parcel); apfFilter.addKeepalivePacketFilter(slot2, ipv6Parcel); apfFilter.addTcpKeepalivePacketFilter(slot1, parcel); apfFilter.addTcpKeepalivePacketFilter(slot2, ipv6Parcel); program = cb.getApfProgram(); // Verify IPv4 keepalive ack packet is dropped Loading services/net/java/android/net/ip/IIpClient.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net.ip; import android.net.ProxyInfo; import android.net.ProvisioningConfigurationParcelable; import android.net.NattKeepalivePacketDataParcelable; import android.net.TcpKeepalivePacketDataParcelable; /** @hide */ Loading @@ -33,4 +34,5 @@ oneway interface IIpClient { void addKeepalivePacketFilter(int slot, in TcpKeepalivePacketDataParcelable pkt); void removeKeepalivePacketFilter(int slot); void setL2KeyAndGroupHint(in String l2Key, in String groupHint); void addNattKeepalivePacketFilter(int slot, in NattKeepalivePacketDataParcelable pkt); } tests/net/java/com/android/server/ConnectivityServiceTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -567,6 +567,16 @@ public class ConnectivityServiceTest { protected void preventAutomaticReconnect() { mPreventReconnectReceived.open(); } @Override protected void addKeepalivePacketFilter(Message msg) { Log.i(TAG, "Add keepalive packet filter."); } @Override protected void removeKeepalivePacketFilter(Message msg) { Log.i(TAG, "Remove keepalive packet filter."); } }; assertEquals(mNetworkAgent.netId, nmNetworkCaptor.getValue().netId); Loading Loading
packages/NetworkStack/src/android/net/apf/ApfFilter.java +15 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NattKeepalivePacketDataParcelable; import android.net.TcpKeepalivePacketDataParcelable; import android.net.apf.ApfGenerator.IllegalInstructionException; import android.net.apf.ApfGenerator.Register; Loading Loading @@ -1691,13 +1692,13 @@ public class ApfFilter { } /** * Add keepalive ack packet filter. * Add TCP keepalive ack packet filter. * This will add a filter to drop acks to the keepalive packet passed as an argument. * * @param slot The index used to access the filter. * @param sentKeepalivePacket The attributes of the sent keepalive packet. */ public synchronized void addKeepalivePacketFilter(final int slot, public synchronized void addTcpKeepalivePacketFilter(final int slot, final TcpKeepalivePacketDataParcelable sentKeepalivePacket) { log("Adding keepalive ack(" + slot + ")"); if (null != mKeepaliveAcks.get(slot)) { Loading @@ -1710,6 +1711,18 @@ public class ApfFilter { installNewProgramLocked(); } /** * Add NATT keepalive packet filter. * This will add a filter to drop NATT keepalive packet which is passed as an argument. * * @param slot The index used to access the filter. * @param sentKeepalivePacket The attributes of the sent keepalive packet. */ public synchronized void addNattKeepalivePacketFilter(final int slot, final NattKeepalivePacketDataParcelable sentKeepalivePacket) { Log.e(TAG, "APF add NATT keepalive filter is not implemented"); } /** * Remove keepalive packet filter. * Loading
packages/NetworkStack/src/android/net/ip/IpClient.java +30 −4 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.net.INetd; import android.net.IpPrefix; import android.net.LinkAddress; import android.net.LinkProperties; import android.net.NattKeepalivePacketDataParcelable; import android.net.NetworkStackIpMemoryStore; import android.net.ProvisioningConfigurationParcelable; import android.net.ProxyInfo; Loading Loading @@ -371,6 +372,10 @@ public class IpClient extends StateMachine { private boolean mMulticastFiltering; private long mStartTimeMillis; /* This must match the definition in KeepaliveTracker.KeepaliveInfo */ private static final int TYPE_NATT = 1; private static final int TYPE_TCP = 2; /** * Reading the snapshot is an asynchronous operation initiated by invoking * Callback.startReadPacketFilter() and completed when the WiFi Service responds with an Loading Loading @@ -553,6 +558,11 @@ public class IpClient extends StateMachine { IpClient.this.addKeepalivePacketFilter(slot, pkt); } @Override public void addNattKeepalivePacketFilter(int slot, NattKeepalivePacketDataParcelable pkt) { checkNetworkStackCallingPermission(); IpClient.this.addNattKeepalivePacketFilter(slot, pkt); } @Override public void removeKeepalivePacketFilter(int slot) { checkNetworkStackCallingPermission(); IpClient.this.removeKeepalivePacketFilter(slot); Loading Loading @@ -691,11 +701,20 @@ public class IpClient extends StateMachine { } /** * Called by WifiStateMachine to add keepalive packet filter before setting up * Called by WifiStateMachine to add TCP keepalive packet filter before setting up * keepalive offload. */ public void addKeepalivePacketFilter(int slot, @NonNull TcpKeepalivePacketDataParcelable pkt) { sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF, slot, 0 /* Unused */, pkt); sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF, slot, TYPE_TCP, pkt); } /** * Called by WifiStateMachine to add NATT keepalive packet filter before setting up * keepalive offload. */ public void addNattKeepalivePacketFilter(int slot, @NonNull NattKeepalivePacketDataParcelable pkt) { sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF, slot, TYPE_NATT, pkt); } /** Loading Loading @@ -1607,10 +1626,17 @@ public class IpClient extends StateMachine { case CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF: { final int slot = msg.arg1; final int type = msg.arg2; if (mApfFilter != null) { mApfFilter.addKeepalivePacketFilter(slot, if (type == TYPE_NATT) { mApfFilter.addNattKeepalivePacketFilter(slot, (NattKeepalivePacketDataParcelable) msg.obj); } else { mApfFilter.addTcpKeepalivePacketFilter(slot, (TcpKeepalivePacketDataParcelable) msg.obj); } } break; } Loading
packages/NetworkStack/tests/src/android/net/apf/ApfTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -1553,7 +1553,7 @@ public class ApfTest { parcel.seq = seqNum; parcel.ack = ackNum; apfFilter.addKeepalivePacketFilter(slot1, parcel); apfFilter.addTcpKeepalivePacketFilter(slot1, parcel); program = cb.getApfProgram(); // Verify IPv4 keepalive ack packet is dropped Loading Loading @@ -1592,7 +1592,7 @@ public class ApfTest { ipv6Parcel.seq = seqNum; ipv6Parcel.ack = ackNum; apfFilter.addKeepalivePacketFilter(slot1, ipv6Parcel); apfFilter.addTcpKeepalivePacketFilter(slot1, ipv6Parcel); program = cb.getApfProgram(); // Verify IPv6 keepalive ack packet is dropped Loading @@ -1614,8 +1614,8 @@ public class ApfTest { apfFilter.removeKeepalivePacketFilter(slot1); // Verify multiple filters apfFilter.addKeepalivePacketFilter(slot1, parcel); apfFilter.addKeepalivePacketFilter(slot2, ipv6Parcel); apfFilter.addTcpKeepalivePacketFilter(slot1, parcel); apfFilter.addTcpKeepalivePacketFilter(slot2, ipv6Parcel); program = cb.getApfProgram(); // Verify IPv4 keepalive ack packet is dropped Loading
services/net/java/android/net/ip/IIpClient.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.net.ip; import android.net.ProxyInfo; import android.net.ProvisioningConfigurationParcelable; import android.net.NattKeepalivePacketDataParcelable; import android.net.TcpKeepalivePacketDataParcelable; /** @hide */ Loading @@ -33,4 +34,5 @@ oneway interface IIpClient { void addKeepalivePacketFilter(int slot, in TcpKeepalivePacketDataParcelable pkt); void removeKeepalivePacketFilter(int slot); void setL2KeyAndGroupHint(in String l2Key, in String groupHint); void addNattKeepalivePacketFilter(int slot, in NattKeepalivePacketDataParcelable pkt); }
tests/net/java/com/android/server/ConnectivityServiceTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -567,6 +567,16 @@ public class ConnectivityServiceTest { protected void preventAutomaticReconnect() { mPreventReconnectReceived.open(); } @Override protected void addKeepalivePacketFilter(Message msg) { Log.i(TAG, "Add keepalive packet filter."); } @Override protected void removeKeepalivePacketFilter(Message msg) { Log.i(TAG, "Remove keepalive packet filter."); } }; assertEquals(mNetworkAgent.netId, nmNetworkCaptor.getValue().netId); Loading