Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
| 17 | package android.net; |
| 18 | |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 19 | import android.annotation.NonNull; |
| 20 | import android.annotation.Nullable; |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
| 22 | import android.annotation.TestApi; |
Artur Satayev | 2695800 | 2019-12-10 17:47:52 +0000 | [diff] [blame] | 23 | import android.compat.annotation.UnsupportedAppUsage; |
Remi NGUYEN VAN | 231b52b | 2019-01-29 15:38:52 +0900 | [diff] [blame] | 24 | import android.net.shared.InetAddressUtils; |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 25 | import android.os.Parcel; |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 26 | import android.os.Parcelable; |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 27 | |
Roshan Pius | ae07689 | 2019-11-14 12:20:41 -0800 | [diff] [blame] | 28 | import com.android.internal.util.Preconditions; |
| 29 | |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 30 | import java.net.InetAddress; |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 31 | import java.util.ArrayList; |
| 32 | import java.util.List; |
| 33 | import java.util.Objects; |
| 34 | |
| 35 | /** |
| 36 | * Class that describes static IP configuration. |
| 37 | * |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 38 | * <p>This class is different from {@link LinkProperties} because it represents |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 39 | * configuration intent. The general contract is that if we can represent |
| 40 | * a configuration here, then we should be able to configure it on a network. |
| 41 | * The intent is that it closely match the UI we have for configuring networks. |
| 42 | * |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 43 | * <p>In contrast, {@link LinkProperties} represents current state. It is much more |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 44 | * expressive. For example, it supports multiple IP addresses, multiple routes, |
| 45 | * stacked interfaces, and so on. Because LinkProperties is so expressive, |
| 46 | * using it to represent configuration intent as well as current state causes |
| 47 | * problems. For example, we could unknowingly save a configuration that we are |
| 48 | * not in fact capable of applying, or we could save a configuration that the |
| 49 | * UI cannot display, which has the potential for malicious code to hide |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 50 | * hostile or unexpected configuration from the user. |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 51 | * |
| 52 | * @hide |
| 53 | */ |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 54 | @SystemApi |
| 55 | @TestApi |
| 56 | public final class StaticIpConfiguration implements Parcelable { |
| 57 | /** @hide */ |
Chalard Jean | 25f1828 | 2019-05-22 22:01:23 +0900 | [diff] [blame] | 58 | @UnsupportedAppUsage |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 59 | @Nullable |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 60 | public LinkAddress ipAddress; |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 61 | /** @hide */ |
Chalard Jean | 9c30530 | 2019-05-20 15:45:04 +0900 | [diff] [blame] | 62 | @UnsupportedAppUsage |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 63 | @Nullable |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 64 | public InetAddress gateway; |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 65 | /** @hide */ |
Chalard Jean | 9c30530 | 2019-05-20 15:45:04 +0900 | [diff] [blame] | 66 | @UnsupportedAppUsage |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 67 | @NonNull |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 68 | public final ArrayList<InetAddress> dnsServers; |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 69 | /** @hide */ |
Chalard Jean | 9c30530 | 2019-05-20 15:45:04 +0900 | [diff] [blame] | 70 | @UnsupportedAppUsage |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 71 | @Nullable |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 72 | public String domains; |
| 73 | |
| 74 | public StaticIpConfiguration() { |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 75 | dnsServers = new ArrayList<>(); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 76 | } |
| 77 | |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 78 | public StaticIpConfiguration(@Nullable StaticIpConfiguration source) { |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 79 | this(); |
| 80 | if (source != null) { |
| 81 | // All of these except dnsServers are immutable, so no need to make copies. |
| 82 | ipAddress = source.ipAddress; |
| 83 | gateway = source.gateway; |
| 84 | dnsServers.addAll(source.dnsServers); |
| 85 | domains = source.domains; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | public void clear() { |
| 90 | ipAddress = null; |
| 91 | gateway = null; |
| 92 | dnsServers.clear(); |
| 93 | domains = null; |
| 94 | } |
| 95 | |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 96 | /** |
| 97 | * Get the static IP address included in the configuration. |
| 98 | */ |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 99 | public @Nullable LinkAddress getIpAddress() { |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 100 | return ipAddress; |
| 101 | } |
| 102 | |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 103 | /** |
| 104 | * Get the gateway included in the configuration. |
| 105 | */ |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 106 | public @Nullable InetAddress getGateway() { |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 107 | return gateway; |
| 108 | } |
| 109 | |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 110 | /** |
| 111 | * Get the DNS servers included in the configuration. |
| 112 | */ |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 113 | public @NonNull List<InetAddress> getDnsServers() { |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 114 | return dnsServers; |
| 115 | } |
| 116 | |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 117 | /** |
Remi NGUYEN VAN | 28aef54 | 2019-04-03 15:54:25 +0900 | [diff] [blame] | 118 | * Get a {@link String} containing the comma separated domains to search when resolving host |
| 119 | * names on this link, in priority order. |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 120 | */ |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 121 | public @Nullable String getDomains() { |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 122 | return domains; |
| 123 | } |
| 124 | |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 125 | /** |
| 126 | * Helper class to build a new instance of {@link StaticIpConfiguration}. |
| 127 | */ |
| 128 | public static final class Builder { |
| 129 | private LinkAddress mIpAddress; |
| 130 | private InetAddress mGateway; |
| 131 | private Iterable<InetAddress> mDnsServers; |
| 132 | private String mDomains; |
| 133 | |
| 134 | /** |
| 135 | * Set the IP address to be included in the configuration; null by default. |
| 136 | * @return The {@link Builder} for chaining. |
| 137 | */ |
| 138 | public @NonNull Builder setIpAddress(@Nullable LinkAddress ipAddress) { |
| 139 | mIpAddress = ipAddress; |
| 140 | return this; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Set the address of the gateway to be included in the configuration; null by default. |
| 145 | * @return The {@link Builder} for chaining. |
| 146 | */ |
| 147 | public @NonNull Builder setGateway(@Nullable InetAddress gateway) { |
| 148 | mGateway = gateway; |
| 149 | return this; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Set the addresses of the DNS servers included in the configuration; empty by default. |
| 154 | * @return The {@link Builder} for chaining. |
| 155 | */ |
| 156 | public @NonNull Builder setDnsServers(@NonNull Iterable<InetAddress> dnsServers) { |
Roshan Pius | ae07689 | 2019-11-14 12:20:41 -0800 | [diff] [blame] | 157 | Preconditions.checkNotNull(dnsServers); |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 158 | mDnsServers = dnsServers; |
| 159 | return this; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Sets the DNS domain search path to be used on the link; null by default. |
| 164 | * @param newDomains A {@link String} containing the comma separated domains to search when |
| 165 | * resolving host names on this link, in priority order. |
| 166 | * @return The {@link Builder} for chaining. |
| 167 | */ |
| 168 | public @NonNull Builder setDomains(@Nullable String newDomains) { |
| 169 | mDomains = newDomains; |
| 170 | return this; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Create a {@link StaticIpConfiguration} from the parameters in this {@link Builder}. |
| 175 | * @return The newly created StaticIpConfiguration. |
| 176 | */ |
| 177 | public @NonNull StaticIpConfiguration build() { |
| 178 | final StaticIpConfiguration config = new StaticIpConfiguration(); |
| 179 | config.ipAddress = mIpAddress; |
| 180 | config.gateway = mGateway; |
Roshan Pius | ae07689 | 2019-11-14 12:20:41 -0800 | [diff] [blame] | 181 | if (mDnsServers != null) { |
| 182 | for (InetAddress server : mDnsServers) { |
| 183 | config.dnsServers.add(server); |
| 184 | } |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 185 | } |
| 186 | config.domains = mDomains; |
| 187 | return config; |
| 188 | } |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Add a DNS server to this configuration. |
| 193 | */ |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 194 | public void addDnsServer(@NonNull InetAddress server) { |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 195 | dnsServers.add(server); |
| 196 | } |
| 197 | |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 198 | /** |
| 199 | * Returns the network routes specified by this object. Will typically include a |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 200 | * directly-connected route for the IP address's local subnet and a default route. |
| 201 | * @param iface Interface to include in the routes. |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 202 | */ |
Remi NGUYEN VAN | 45ecef3 | 2019-03-25 16:41:08 +0900 | [diff] [blame] | 203 | public @NonNull List<RouteInfo> getRoutes(@Nullable String iface) { |
Lorenzo Colitti | 8316b819 | 2015-01-20 15:53:02 +0900 | [diff] [blame] | 204 | List<RouteInfo> routes = new ArrayList<RouteInfo>(3); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 205 | if (ipAddress != null) { |
Lorenzo Colitti | 8316b819 | 2015-01-20 15:53:02 +0900 | [diff] [blame] | 206 | RouteInfo connectedRoute = new RouteInfo(ipAddress, null, iface); |
| 207 | routes.add(connectedRoute); |
Remi NGUYEN VAN | 59a06a0 | 2019-04-01 17:09:05 +0900 | [diff] [blame] | 208 | // If the default gateway is not covered by the directly-connected route, also add a |
| 209 | // host route to the gateway as well. This configuration is arguably invalid, but it |
| 210 | // used to work in K and earlier, and other OSes appear to accept it. |
Lorenzo Colitti | 8316b819 | 2015-01-20 15:53:02 +0900 | [diff] [blame] | 211 | if (gateway != null && !connectedRoute.matches(gateway)) { |
| 212 | routes.add(RouteInfo.makeHostRoute(gateway, iface)); |
| 213 | } |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 214 | } |
| 215 | if (gateway != null) { |
Lorenzo Colitti | 8316b819 | 2015-01-20 15:53:02 +0900 | [diff] [blame] | 216 | routes.add(new RouteInfo((IpPrefix) null, gateway, iface)); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 217 | } |
| 218 | return routes; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Returns a LinkProperties object expressing the data in this object. Note that the information |
| 223 | * contained in the LinkProperties will not be a complete picture of the link's configuration, |
| 224 | * because any configuration information that is obtained dynamically by the network (e.g., |
| 225 | * IPv6 configuration) will not be included. |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 226 | * @hide |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 227 | */ |
paulhu | 79b380c | 2019-03-15 17:17:02 +0800 | [diff] [blame] | 228 | public @NonNull LinkProperties toLinkProperties(String iface) { |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 229 | LinkProperties lp = new LinkProperties(); |
| 230 | lp.setInterfaceName(iface); |
| 231 | if (ipAddress != null) { |
| 232 | lp.addLinkAddress(ipAddress); |
| 233 | } |
| 234 | for (RouteInfo route : getRoutes(iface)) { |
| 235 | lp.addRoute(route); |
| 236 | } |
| 237 | for (InetAddress dns : dnsServers) { |
| 238 | lp.addDnsServer(dns); |
| 239 | } |
Paul Jensen | b3b7097 | 2014-11-05 09:35:26 -0500 | [diff] [blame] | 240 | lp.setDomains(domains); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 241 | return lp; |
| 242 | } |
| 243 | |
Aurimas Liutikas | 00be951 | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 244 | @NonNull |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 245 | @Override |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 246 | public String toString() { |
| 247 | StringBuffer str = new StringBuffer(); |
| 248 | |
| 249 | str.append("IP address "); |
| 250 | if (ipAddress != null ) str.append(ipAddress).append(" "); |
| 251 | |
| 252 | str.append("Gateway "); |
| 253 | if (gateway != null) str.append(gateway.getHostAddress()).append(" "); |
| 254 | |
| 255 | str.append(" DNS servers: ["); |
| 256 | for (InetAddress dnsServer : dnsServers) { |
| 257 | str.append(" ").append(dnsServer.getHostAddress()); |
| 258 | } |
| 259 | |
Erik Kline | acda32c | 2016-05-13 17:50:25 +0900 | [diff] [blame] | 260 | str.append(" ] Domains "); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 261 | if (domains != null) str.append(domains); |
| 262 | return str.toString(); |
| 263 | } |
| 264 | |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 265 | @Override |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 266 | public int hashCode() { |
| 267 | int result = 13; |
| 268 | result = 47 * result + (ipAddress == null ? 0 : ipAddress.hashCode()); |
| 269 | result = 47 * result + (gateway == null ? 0 : gateway.hashCode()); |
| 270 | result = 47 * result + (domains == null ? 0 : domains.hashCode()); |
| 271 | result = 47 * result + dnsServers.hashCode(); |
| 272 | return result; |
| 273 | } |
| 274 | |
| 275 | @Override |
Aurimas Liutikas | 00be951 | 2019-08-28 13:01:05 -0700 | [diff] [blame] | 276 | public boolean equals(@Nullable Object obj) { |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 277 | if (this == obj) return true; |
| 278 | |
| 279 | if (!(obj instanceof StaticIpConfiguration)) return false; |
| 280 | |
| 281 | StaticIpConfiguration other = (StaticIpConfiguration) obj; |
| 282 | |
| 283 | return other != null && |
| 284 | Objects.equals(ipAddress, other.ipAddress) && |
| 285 | Objects.equals(gateway, other.gateway) && |
| 286 | dnsServers.equals(other.dnsServers) && |
| 287 | Objects.equals(domains, other.domains); |
| 288 | } |
| 289 | |
| 290 | /** Implement the Parcelable interface */ |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame] | 291 | public static final @android.annotation.NonNull Creator<StaticIpConfiguration> CREATOR = |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 292 | new Creator<StaticIpConfiguration>() { |
| 293 | public StaticIpConfiguration createFromParcel(Parcel in) { |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 294 | return readFromParcel(in); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | public StaticIpConfiguration[] newArray(int size) { |
| 298 | return new StaticIpConfiguration[size]; |
| 299 | } |
| 300 | }; |
| 301 | |
| 302 | /** Implement the Parcelable interface */ |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 303 | @Override |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 304 | public int describeContents() { |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /** Implement the Parcelable interface */ |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 309 | @Override |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 310 | public void writeToParcel(Parcel dest, int flags) { |
| 311 | dest.writeParcelable(ipAddress, flags); |
Remi NGUYEN VAN | 231b52b | 2019-01-29 15:38:52 +0900 | [diff] [blame] | 312 | InetAddressUtils.parcelInetAddress(dest, gateway, flags); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 313 | dest.writeInt(dnsServers.size()); |
| 314 | for (InetAddress dnsServer : dnsServers) { |
Remi NGUYEN VAN | 231b52b | 2019-01-29 15:38:52 +0900 | [diff] [blame] | 315 | InetAddressUtils.parcelInetAddress(dest, dnsServer, flags); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 316 | } |
Lorenzo Colitti | d0cc544 | 2015-01-29 17:10:52 +0900 | [diff] [blame] | 317 | dest.writeString(domains); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 318 | } |
| 319 | |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 320 | /** @hide */ |
| 321 | public static StaticIpConfiguration readFromParcel(Parcel in) { |
| 322 | final StaticIpConfiguration s = new StaticIpConfiguration(); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 323 | s.ipAddress = in.readParcelable(null); |
Remi NGUYEN VAN | 231b52b | 2019-01-29 15:38:52 +0900 | [diff] [blame] | 324 | s.gateway = InetAddressUtils.unparcelInetAddress(in); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 325 | s.dnsServers.clear(); |
| 326 | int size = in.readInt(); |
| 327 | for (int i = 0; i < size; i++) { |
Remi NGUYEN VAN | 231b52b | 2019-01-29 15:38:52 +0900 | [diff] [blame] | 328 | s.dnsServers.add(InetAddressUtils.unparcelInetAddress(in)); |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 329 | } |
Lorenzo Colitti | d0cc544 | 2015-01-29 17:10:52 +0900 | [diff] [blame] | 330 | s.domains = in.readString(); |
Remi NGUYEN VAN | a4bcc86 | 2019-01-28 13:28:35 +0900 | [diff] [blame] | 331 | return s; |
Lorenzo Colitti | 0a82e80 | 2014-07-31 00:48:01 +0900 | [diff] [blame] | 332 | } |
| 333 | } |