diff options
author | Chalard Jean <jchalard@google.com> | 2019-03-15 23:10:40 +0900 |
---|---|---|
committer | Chalard Jean <jchalard@google.com> | 2019-04-09 07:55:17 +0000 |
commit | 0c44f91744d1a1b267e6e475a7f4aaddb59bb5ec (patch) | |
tree | ecfe19a64ad3119f81d7e3fee58e444cc3e8bf01 /src | |
parent | 8183edaf546a25550a60c7bc1be0bf79746b2178 (diff) |
Add a mechanism to pass the L2Key and group hint to IpClient
Test: IpClientTest
Bug: 128803828
Change-Id: I399b20ce29a385a74971b7a7248a48cb4d66deb6
(cherry picked from commit 3cab290648a0a0f6e5f6c64c2225b3661aabba2f)
Diffstat (limited to 'src')
-rw-r--r-- | src/android/net/ip/IpClient.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index c1f178a..80d139c 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java @@ -51,6 +51,7 @@ import android.os.SystemClock; import android.text.TextUtils; import android.util.LocalLog; import android.util.Log; +import android.util.Pair; import android.util.SparseArray; import com.android.internal.annotations.VisibleForTesting; @@ -298,6 +299,7 @@ public class IpClient extends StateMachine { private static final int EVENT_READ_PACKET_FILTER_COMPLETE = 12; private static final int CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF = 13; private static final int CMD_REMOVE_KEEPALIVE_PACKET_FILTER_FROM_APF = 14; + private static final int CMD_UPDATE_L2KEY_GROUPHINT = 15; // Internal commands to use instead of trying to call transitionTo() inside // a given State's enter() method. Calling transitionTo() from enter/exit @@ -364,6 +366,8 @@ public class IpClient extends StateMachine { private String mTcpBufferSizes; private ProxyInfo mHttpProxy; private ApfFilter mApfFilter; + private String mL2Key; // The L2 key for this network, for writing into the memory store + private String mGroupHint; // The group hint for this network, for writing into the memory store private boolean mMulticastFiltering; private long mStartTimeMillis; @@ -524,6 +528,11 @@ public class IpClient extends StateMachine { IpClient.this.stop(); } @Override + public void setL2KeyAndGroupHint(String l2Key, String groupHint) { + checkNetworkStackCallingPermission(); + IpClient.this.setL2KeyAndGroupHint(l2Key, groupHint); + } + @Override public void setTcpBufferSizes(String tcpBufferSizes) { checkNetworkStackCallingPermission(); IpClient.this.setTcpBufferSizes(tcpBufferSizes); @@ -652,6 +661,13 @@ public class IpClient extends StateMachine { } /** + * Set the L2 key and group hint for storing info into the memory store. + */ + public void setL2KeyAndGroupHint(String l2Key, String groupHint) { + sendMessage(CMD_UPDATE_L2KEY_GROUPHINT, new Pair<>(l2Key, groupHint)); + } + + /** * Set the HTTP Proxy configuration to use. * * This may be called, repeatedly, at any time before or after a call to @@ -1068,6 +1084,10 @@ public class IpClient extends StateMachine { return true; } final int delta = setLinkProperties(newLp); + // Most of the attributes stored in the memory store are deduced from + // the link properties, therefore when the properties update the memory + // store record should be updated too. + maybeSaveNetworkToIpMemoryStore(); if (sendCallbacks) { dispatchCallback(delta, newLp); } @@ -1083,6 +1103,7 @@ public class IpClient extends StateMachine { Log.d(mTag, "onNewDhcpResults(" + Objects.toString(dhcpResults) + ")"); } mCallback.onNewDhcpResults(dhcpResults); + maybeSaveNetworkToIpMemoryStore(); dispatchCallback(delta, newLp); } @@ -1213,6 +1234,10 @@ public class IpClient extends StateMachine { mInterfaceCtrl.clearAllAddresses(); } + private void maybeSaveNetworkToIpMemoryStore() { + // TODO : implement this + } + class StoppedState extends State { @Override public void enter() { @@ -1258,6 +1283,13 @@ public class IpClient extends StateMachine { handleLinkPropertiesUpdate(NO_CALLBACKS); break; + case CMD_UPDATE_L2KEY_GROUPHINT: { + final Pair<String, String> args = (Pair<String, String>) msg.obj; + mL2Key = args.first; + mGroupHint = args.second; + break; + } + case CMD_SET_MULTICAST_FILTER: mMulticastFiltering = (boolean) msg.obj; break; @@ -1357,6 +1389,20 @@ public class IpClient extends StateMachine { } break; + case CMD_UPDATE_L2KEY_GROUPHINT: { + final Pair<String, String> args = (Pair<String, String>) msg.obj; + mL2Key = args.first; + mGroupHint = args.second; + // TODO : attributes should be saved to the memory store with + // these new values if they differ from the previous ones. + // If the state machine is in pure StartedState, then the values to input + // are not known yet and should be updated when the LinkProperties are updated. + // If the state machine is in RunningState (which is a child of StartedState) + // then the next NUD check should be used to store the new values to avoid + // inputting current values for what may be a different L3 network. + break; + } + case EVENT_PROVISIONING_TIMEOUT: handleProvisioningFailure(); break; |