Send message to add/remove NAT-T keepalive packet filter.

Remove definition of TYPE_NATT and TYPE_TCP since the type
can be identified by checking message.obj is an instance of
NattKeepalivePacketData or TcpKeepalivePacketData.
It's more simple and won't have dependency on KeepaliveInfo.

Bug: 33530442
Test: atest FrameworksNetTests
      atest NetworkStackTests

Change-Id: Ic97ffe9ff5781778efd264460809f5059f0f4230
This commit is contained in:
Aaron Huang
2019-05-02 21:14:20 +08:00
parent c586bdf976
commit 77abd94876

View File

@@ -347,6 +347,8 @@ public class KeepaliveTracker {
Log.d(TAG, "Starting keepalive " + mSlot + " on " + mNai.name()); Log.d(TAG, "Starting keepalive " + mSlot + " on " + mNai.name());
switch (mType) { switch (mType) {
case TYPE_NATT: case TYPE_NATT:
mNai.asyncChannel.sendMessage(
CMD_ADD_KEEPALIVE_PACKET_FILTER, slot, 0 /* Unused */, mPacket);
mNai.asyncChannel mNai.asyncChannel
.sendMessage(CMD_START_SOCKET_KEEPALIVE, slot, mInterval, mPacket); .sendMessage(CMD_START_SOCKET_KEEPALIVE, slot, mInterval, mPacket);
break; break;
@@ -357,9 +359,8 @@ public class KeepaliveTracker {
handleStopKeepalive(mNai, mSlot, ERROR_INVALID_SOCKET); handleStopKeepalive(mNai, mSlot, ERROR_INVALID_SOCKET);
return; return;
} }
mNai.asyncChannel mNai.asyncChannel.sendMessage(
.sendMessage(CMD_ADD_KEEPALIVE_PACKET_FILTER, slot, 0 /* Unused */, CMD_ADD_KEEPALIVE_PACKET_FILTER, slot, 0 /* Unused */, mPacket);
mPacket);
// TODO: check result from apf and notify of failure as needed. // TODO: check result from apf and notify of failure as needed.
mNai.asyncChannel mNai.asyncChannel
.sendMessage(CMD_START_SOCKET_KEEPALIVE, slot, mInterval, mPacket); .sendMessage(CMD_START_SOCKET_KEEPALIVE, slot, mInterval, mPacket);
@@ -395,13 +396,16 @@ public class KeepaliveTracker {
return; return;
default: default:
mStartedState = STOPPING; mStartedState = STOPPING;
if (mType == TYPE_NATT) { switch (mType) {
mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot); case TYPE_TCP:
} else if (mType == TYPE_TCP) {
mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot);
mNai.asyncChannel.sendMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER, mSlot);
mTcpController.stopSocketMonitor(mSlot); mTcpController.stopSocketMonitor(mSlot);
} else { // fall through
case TYPE_NATT:
mNai.asyncChannel.sendMessage(CMD_STOP_SOCKET_KEEPALIVE, mSlot);
mNai.asyncChannel.sendMessage(CMD_REMOVE_KEEPALIVE_PACKET_FILTER,
mSlot);
break;
default:
Log.wtf(TAG, "Stopping keepalive with unknown type: " + mType); Log.wtf(TAG, "Stopping keepalive with unknown type: " + mType);
} }
} }