Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package android.net; |
| 17 | |
Chalard Jean | 9c0ff1b | 2019-05-30 17:11:14 +0900 | [diff] [blame] | 18 | import android.annotation.Nullable; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 21 | |
| 22 | import com.android.internal.annotations.VisibleForTesting; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 23 | |
Jonathan Basseri | c61b70d | 2017-04-21 15:53:51 -0700 | [diff] [blame] | 24 | /** |
| 25 | * This class encapsulates all the configuration parameters needed to create IPsec transforms and |
| 26 | * policies. |
| 27 | * |
| 28 | * @hide |
| 29 | */ |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 30 | public final class IpSecConfig implements Parcelable { |
Nathan Harold | 93962f3 | 2017-03-07 13:23:36 -0800 | [diff] [blame] | 31 | private static final String TAG = "IpSecConfig"; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 32 | |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 33 | // MODE_TRANSPORT or MODE_TUNNEL |
| 34 | private int mMode = IpSecTransform.MODE_TRANSPORT; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 35 | |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 36 | // Preventing this from being null simplifies Java->Native binder |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 37 | private String mSourceAddress = ""; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 38 | |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 39 | // Preventing this from being null simplifies Java->Native binder |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 40 | private String mDestinationAddress = ""; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 41 | |
Nathan Harold | d6f50b2 | 2017-10-04 12:58:55 -0700 | [diff] [blame] | 42 | // The underlying Network that represents the "gateway" Network |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 43 | // for outbound packets. It may also be used to select packets. |
| 44 | private Network mNetwork; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 45 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 46 | // Minimum requirements for identifying a transform |
| 47 | // SPI identifying the IPsec SA in packet processing |
| 48 | // and a destination IP address |
| 49 | private int mSpiResourceId = IpSecManager.INVALID_RESOURCE_ID; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 50 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 51 | // Encryption Algorithm |
| 52 | private IpSecAlgorithm mEncryption; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 53 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 54 | // Authentication Algorithm |
| 55 | private IpSecAlgorithm mAuthentication; |
ludi | b0c95b1 | 2017-05-22 10:52:23 -0700 | [diff] [blame] | 56 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 57 | // Authenticated Encryption Algorithm |
| 58 | private IpSecAlgorithm mAuthenticatedEncryption; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 59 | |
| 60 | // For tunnel mode IPv4 UDP Encapsulation |
| 61 | // IpSecTransform#ENCAP_ESP_*, such as ENCAP_ESP_OVER_UDP_IKE |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 62 | private int mEncapType = IpSecTransform.ENCAP_NONE; |
| 63 | private int mEncapSocketResourceId = IpSecManager.INVALID_RESOURCE_ID; |
| 64 | private int mEncapRemotePort; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 65 | |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 66 | // An interval, in seconds between the NattKeepalive packets |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 67 | private int mNattKeepaliveInterval; |
| 68 | |
Benedict Wong | ab80e1f | 2018-07-25 18:46:19 -0700 | [diff] [blame] | 69 | // XFRM mark and mask; defaults to 0 (no mark/mask) |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 70 | private int mMarkValue; |
| 71 | private int mMarkMask; |
| 72 | |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 73 | // XFRM interface id |
| 74 | private int mXfrmInterfaceId; |
| 75 | |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 76 | /** Set the mode for this IPsec transform */ |
| 77 | public void setMode(int mode) { |
| 78 | mMode = mode; |
| 79 | } |
| 80 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 81 | /** Set the source IP addres for this IPsec transform */ |
| 82 | public void setSourceAddress(String sourceAddress) { |
| 83 | mSourceAddress = sourceAddress; |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 86 | /** Set the destination IP address for this IPsec transform */ |
| 87 | public void setDestinationAddress(String destinationAddress) { |
| 88 | mDestinationAddress = destinationAddress; |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 91 | /** Set the SPI by resource ID */ |
| 92 | public void setSpiResourceId(int resourceId) { |
| 93 | mSpiResourceId = resourceId; |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 96 | /** Set the encryption algorithm */ |
| 97 | public void setEncryption(IpSecAlgorithm encryption) { |
| 98 | mEncryption = encryption; |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 101 | /** Set the authentication algorithm */ |
| 102 | public void setAuthentication(IpSecAlgorithm authentication) { |
| 103 | mAuthentication = authentication; |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 106 | /** Set the authenticated encryption algorithm */ |
| 107 | public void setAuthenticatedEncryption(IpSecAlgorithm authenticatedEncryption) { |
| 108 | mAuthenticatedEncryption = authenticatedEncryption; |
Benedict Wong | 0febe5e | 2017-08-22 21:42:33 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 111 | /** Set the underlying network that will carry traffic for this transform */ |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 112 | public void setNetwork(Network network) { |
| 113 | mNetwork = network; |
| 114 | } |
| 115 | |
| 116 | public void setEncapType(int encapType) { |
| 117 | mEncapType = encapType; |
| 118 | } |
| 119 | |
| 120 | public void setEncapSocketResourceId(int resourceId) { |
| 121 | mEncapSocketResourceId = resourceId; |
| 122 | } |
| 123 | |
| 124 | public void setEncapRemotePort(int port) { |
| 125 | mEncapRemotePort = port; |
| 126 | } |
| 127 | |
| 128 | public void setNattKeepaliveInterval(int interval) { |
| 129 | mNattKeepaliveInterval = interval; |
| 130 | } |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 131 | |
Benedict Wong | ab80e1f | 2018-07-25 18:46:19 -0700 | [diff] [blame] | 132 | /** |
| 133 | * Sets the mark value |
| 134 | * |
| 135 | * <p>Internal (System server) use only. Marks passed in by users will be overwritten or |
| 136 | * ignored. |
| 137 | */ |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 138 | public void setMarkValue(int mark) { |
| 139 | mMarkValue = mark; |
| 140 | } |
| 141 | |
Benedict Wong | ab80e1f | 2018-07-25 18:46:19 -0700 | [diff] [blame] | 142 | /** |
| 143 | * Sets the mark mask |
| 144 | * |
| 145 | * <p>Internal (System server) use only. Marks passed in by users will be overwritten or |
| 146 | * ignored. |
| 147 | */ |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 148 | public void setMarkMask(int mask) { |
| 149 | mMarkMask = mask; |
| 150 | } |
| 151 | |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 152 | public void setXfrmInterfaceId(int xfrmInterfaceId) { |
| 153 | mXfrmInterfaceId = xfrmInterfaceId; |
| 154 | } |
| 155 | |
Nathan Harold | 93962f3 | 2017-03-07 13:23:36 -0800 | [diff] [blame] | 156 | // Transport or Tunnel |
| 157 | public int getMode() { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 158 | return mMode; |
Nathan Harold | 93962f3 | 2017-03-07 13:23:36 -0800 | [diff] [blame] | 159 | } |
| 160 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 161 | public String getSourceAddress() { |
| 162 | return mSourceAddress; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 163 | } |
| 164 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 165 | public int getSpiResourceId() { |
| 166 | return mSpiResourceId; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 167 | } |
| 168 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 169 | public String getDestinationAddress() { |
| 170 | return mDestinationAddress; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 171 | } |
| 172 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 173 | public IpSecAlgorithm getEncryption() { |
| 174 | return mEncryption; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 175 | } |
| 176 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 177 | public IpSecAlgorithm getAuthentication() { |
| 178 | return mAuthentication; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 181 | public IpSecAlgorithm getAuthenticatedEncryption() { |
| 182 | return mAuthenticatedEncryption; |
Benedict Wong | 0febe5e | 2017-08-22 21:42:33 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Nathan Harold | 93962f3 | 2017-03-07 13:23:36 -0800 | [diff] [blame] | 185 | public Network getNetwork() { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 186 | return mNetwork; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | public int getEncapType() { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 190 | return mEncapType; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 191 | } |
| 192 | |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 193 | public int getEncapSocketResourceId() { |
| 194 | return mEncapSocketResourceId; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | public int getEncapRemotePort() { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 198 | return mEncapRemotePort; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 199 | } |
| 200 | |
Nathan Harold | 93962f3 | 2017-03-07 13:23:36 -0800 | [diff] [blame] | 201 | public int getNattKeepaliveInterval() { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 202 | return mNattKeepaliveInterval; |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 203 | } |
| 204 | |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 205 | public int getMarkValue() { |
| 206 | return mMarkValue; |
| 207 | } |
| 208 | |
| 209 | public int getMarkMask() { |
| 210 | return mMarkMask; |
| 211 | } |
| 212 | |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 213 | public int getXfrmInterfaceId() { |
| 214 | return mXfrmInterfaceId; |
| 215 | } |
| 216 | |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 217 | // Parcelable Methods |
| 218 | |
| 219 | @Override |
| 220 | public int describeContents() { |
| 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | @Override |
| 225 | public void writeToParcel(Parcel out, int flags) { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 226 | out.writeInt(mMode); |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 227 | out.writeString(mSourceAddress); |
| 228 | out.writeString(mDestinationAddress); |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 229 | out.writeParcelable(mNetwork, flags); |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 230 | out.writeInt(mSpiResourceId); |
| 231 | out.writeParcelable(mEncryption, flags); |
| 232 | out.writeParcelable(mAuthentication, flags); |
| 233 | out.writeParcelable(mAuthenticatedEncryption, flags); |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 234 | out.writeInt(mEncapType); |
| 235 | out.writeInt(mEncapSocketResourceId); |
| 236 | out.writeInt(mEncapRemotePort); |
Nathan Harold | 19ce70b | 2017-09-25 19:33:13 -0700 | [diff] [blame] | 237 | out.writeInt(mNattKeepaliveInterval); |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 238 | out.writeInt(mMarkValue); |
| 239 | out.writeInt(mMarkMask); |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 240 | out.writeInt(mXfrmInterfaceId); |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 241 | } |
| 242 | |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 243 | @VisibleForTesting |
| 244 | public IpSecConfig() {} |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 245 | |
Benedict Wong | 9dd3a38 | 2018-02-06 20:43:21 -0800 | [diff] [blame] | 246 | /** Copy constructor */ |
| 247 | @VisibleForTesting |
| 248 | public IpSecConfig(IpSecConfig c) { |
| 249 | mMode = c.mMode; |
| 250 | mSourceAddress = c.mSourceAddress; |
| 251 | mDestinationAddress = c.mDestinationAddress; |
| 252 | mNetwork = c.mNetwork; |
| 253 | mSpiResourceId = c.mSpiResourceId; |
| 254 | mEncryption = c.mEncryption; |
| 255 | mAuthentication = c.mAuthentication; |
| 256 | mAuthenticatedEncryption = c.mAuthenticatedEncryption; |
| 257 | mEncapType = c.mEncapType; |
| 258 | mEncapSocketResourceId = c.mEncapSocketResourceId; |
| 259 | mEncapRemotePort = c.mEncapRemotePort; |
| 260 | mNattKeepaliveInterval = c.mNattKeepaliveInterval; |
| 261 | mMarkValue = c.mMarkValue; |
| 262 | mMarkMask = c.mMarkMask; |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 263 | mXfrmInterfaceId = c.mXfrmInterfaceId; |
Benedict Wong | 9dd3a38 | 2018-02-06 20:43:21 -0800 | [diff] [blame] | 264 | } |
| 265 | |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 266 | private IpSecConfig(Parcel in) { |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 267 | mMode = in.readInt(); |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 268 | mSourceAddress = in.readString(); |
| 269 | mDestinationAddress = in.readString(); |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 270 | mNetwork = (Network) in.readParcelable(Network.class.getClassLoader()); |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 271 | mSpiResourceId = in.readInt(); |
| 272 | mEncryption = |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 273 | (IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader()); |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 274 | mAuthentication = |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 275 | (IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader()); |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 276 | mAuthenticatedEncryption = |
Benedict Wong | 0febe5e | 2017-08-22 21:42:33 -0700 | [diff] [blame] | 277 | (IpSecAlgorithm) in.readParcelable(IpSecAlgorithm.class.getClassLoader()); |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 278 | mEncapType = in.readInt(); |
| 279 | mEncapSocketResourceId = in.readInt(); |
| 280 | mEncapRemotePort = in.readInt(); |
Nathan Harold | 19ce70b | 2017-09-25 19:33:13 -0700 | [diff] [blame] | 281 | mNattKeepaliveInterval = in.readInt(); |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 282 | mMarkValue = in.readInt(); |
| 283 | mMarkMask = in.readInt(); |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 284 | mXfrmInterfaceId = in.readInt(); |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 285 | } |
| 286 | |
ludi | b0c95b1 | 2017-05-22 10:52:23 -0700 | [diff] [blame] | 287 | @Override |
| 288 | public String toString() { |
| 289 | StringBuilder strBuilder = new StringBuilder(); |
| 290 | strBuilder |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 291 | .append("{mMode=") |
| 292 | .append(mMode == IpSecTransform.MODE_TUNNEL ? "TUNNEL" : "TRANSPORT") |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 293 | .append(", mSourceAddress=") |
| 294 | .append(mSourceAddress) |
| 295 | .append(", mDestinationAddress=") |
| 296 | .append(mDestinationAddress) |
Nathan Harold | a10003d | 2017-08-23 13:46:33 -0700 | [diff] [blame] | 297 | .append(", mNetwork=") |
| 298 | .append(mNetwork) |
| 299 | .append(", mEncapType=") |
| 300 | .append(mEncapType) |
| 301 | .append(", mEncapSocketResourceId=") |
| 302 | .append(mEncapSocketResourceId) |
| 303 | .append(", mEncapRemotePort=") |
| 304 | .append(mEncapRemotePort) |
| 305 | .append(", mNattKeepaliveInterval=") |
| 306 | .append(mNattKeepaliveInterval) |
Nathan Harold | a252331 | 2018-01-05 19:25:13 -0800 | [diff] [blame] | 307 | .append("{mSpiResourceId=") |
| 308 | .append(mSpiResourceId) |
| 309 | .append(", mEncryption=") |
| 310 | .append(mEncryption) |
| 311 | .append(", mAuthentication=") |
| 312 | .append(mAuthentication) |
| 313 | .append(", mAuthenticatedEncryption=") |
| 314 | .append(mAuthenticatedEncryption) |
Di Lu | 0b611f4 | 2018-01-11 11:35:25 -0800 | [diff] [blame] | 315 | .append(", mMarkValue=") |
| 316 | .append(mMarkValue) |
| 317 | .append(", mMarkMask=") |
| 318 | .append(mMarkMask) |
Benedict Wong | 781dae6 | 2018-09-06 11:31:25 -0700 | [diff] [blame] | 319 | .append(", mXfrmInterfaceId=") |
| 320 | .append(mXfrmInterfaceId) |
ludi | b0c95b1 | 2017-05-22 10:52:23 -0700 | [diff] [blame] | 321 | .append("}"); |
| 322 | |
| 323 | return strBuilder.toString(); |
| 324 | } |
| 325 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 326 | public static final @android.annotation.NonNull Parcelable.Creator<IpSecConfig> CREATOR = |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 327 | new Parcelable.Creator<IpSecConfig>() { |
| 328 | public IpSecConfig createFromParcel(Parcel in) { |
| 329 | return new IpSecConfig(in); |
| 330 | } |
| 331 | |
| 332 | public IpSecConfig[] newArray(int size) { |
| 333 | return new IpSecConfig[size]; |
| 334 | } |
| 335 | }; |
Nathan Harold | 19ce70b | 2017-09-25 19:33:13 -0700 | [diff] [blame] | 336 | |
Chalard Jean | 9c0ff1b | 2019-05-30 17:11:14 +0900 | [diff] [blame] | 337 | @Override |
| 338 | public boolean equals(@Nullable Object other) { |
| 339 | if (!(other instanceof IpSecConfig)) return false; |
| 340 | final IpSecConfig rhs = (IpSecConfig) other; |
| 341 | return (mMode == rhs.mMode |
| 342 | && mSourceAddress.equals(rhs.mSourceAddress) |
| 343 | && mDestinationAddress.equals(rhs.mDestinationAddress) |
| 344 | && ((mNetwork != null && mNetwork.equals(rhs.mNetwork)) |
| 345 | || (mNetwork == rhs.mNetwork)) |
| 346 | && mEncapType == rhs.mEncapType |
| 347 | && mEncapSocketResourceId == rhs.mEncapSocketResourceId |
| 348 | && mEncapRemotePort == rhs.mEncapRemotePort |
| 349 | && mNattKeepaliveInterval == rhs.mNattKeepaliveInterval |
| 350 | && mSpiResourceId == rhs.mSpiResourceId |
| 351 | && IpSecAlgorithm.equals(mEncryption, rhs.mEncryption) |
| 352 | && IpSecAlgorithm.equals(mAuthenticatedEncryption, rhs.mAuthenticatedEncryption) |
| 353 | && IpSecAlgorithm.equals(mAuthentication, rhs.mAuthentication) |
| 354 | && mMarkValue == rhs.mMarkValue |
| 355 | && mMarkMask == rhs.mMarkMask |
| 356 | && mXfrmInterfaceId == rhs.mXfrmInterfaceId); |
Nathan Harold | 19ce70b | 2017-09-25 19:33:13 -0700 | [diff] [blame] | 357 | } |
Nathan Harold | 330e108 | 2017-01-12 18:38:57 -0800 | [diff] [blame] | 358 | } |