Offset 1, 167 lines modifiedOffset 1, 82 lines modified
  
1 package·com.android.networkstack.tethering;1 package·com.android.networkstack.tethering;
  
2 import·java.io.PrintWriter;2 import·java.io.PrintWriter;
3 import·com.android.networkstack.tethering.util.StateMachine;3 import·com.android.networkstack.tethering.util.StateMachine;
4 import·android.net.NetworkCapabilities; 
5 import·android.net.Network; 
6 import·java.util.HashSet;4 import·android.net.LinkProperties;
 5 import·java.net.UnknownHostException;
 6 import·java.net.InetAddress;
7 import·java.util.Random;7 import·java.util.Random;
8 import·com.android.networkstack.tethering.util.IndentingPrintWriter;8 import·com.android.networkstack.tethering.util.IndentingPrintWriter;
9 import·java.net.Inet4Address; 
10 import·android.net.util.PrefixUtils; 
11 import·android.net.ip.IpServer; 
12 import·java.util.Iterator; 
13 import·java.net.InetAddress; 
14 import·com.android.networkstack.tethering.util.Inet4AddressUtils; 
15 import·java.util.Collection;9 import·java.util.Collection;
16 import·java.util.ArrayList; 
17 import·java.util.Arrays;10 import·java.util.Arrays;
18 import·android.net.IpPrefix;11 import·android.net.Network;
 12 import·java.util.Iterator;
 13 import·java.util.ArrayList;
 14 import·java.util.List;
19 import·android.net.LinkAddress;15 import·android.net.LinkAddress;
 16 import·android.net.util.PrefixUtils;
 17 import·android.net.ip.IpServer;
20 import·android.content.Context;18 import·android.content.Context;
21 import·android.util.ArrayMap;19 import·android.util.ArrayMap;
22 import·java.util.List;20 import·android.net.IpPrefix;
23 import·android.util.ArraySet;21 import·android.util.ArraySet;
24 import·android.net.ConnectivityManager;22 import·android.net.ConnectivityManager;
25 import·android.util.SparseArray; 
  
26 public·class·PrivateAddressCoordinator23 public·class·PrivateAddressCoordinator
27 {24 {
28 ····private·final·SparseArray·mCachedAddresses; 
29 ····private·final·TetheringConfiguration·mConfig; 
30 ····private·final·ConnectivityManager·mConnectivityMgr;25 ····private·final·ConnectivityManager·mConnectivityMgr;
31 ····private·final·ArraySet·mDownstreams;26 ····private·final·ArraySet·mDownstreams;
32 ····private·final·List·mTetheringPrefixes;27 ····private·final·IpPrefix·mTetheringPrefix;
33 ····private·final·ArrayMap·mUpstreamPrefixMap;28 ····private·final·ArrayMap·mUpstreamPrefixMap;
34 ····29 ····
35 ····public·PrivateAddressCoordinator(final·Context·context,·final·TetheringConfiguration·mConfig)·{30 ····public·PrivateAddressCoordinator(final·Context·context)·{
36 ········this.mDownstreams·=·new·ArraySet();31 ········this.mDownstreams·=·new·ArraySet();
37 ········this.mUpstreamPrefixMap·=·new·ArrayMap();32 ········this.mUpstreamPrefixMap·=·new·ArrayMap();
 33 ········this.mTetheringPrefix·=·new·IpPrefix("192.168.0.0/16");
38 ········this.mConnectivityMgr·=·(ConnectivityManager)context.getSystemService("connectivity");34 ········this.mConnectivityMgr·=·(ConnectivityManager)context.getSystemService("connectivity");
39 ········this.mConfig·=·mConfig; 
40 ········(this.mCachedAddresses·=·new·SparseArray()).put(2,·(Object)new·LinkAddress("192.168.44.1/24")); 
41 ········this.mCachedAddresses.put(3,·(Object)new·LinkAddress("192.168.49.1/24")); 
42 ········this.mTetheringPrefixes·=·new·ArrayList(Arrays.asList(new·IpPrefix("192.168.0.0/16"))); 
43 ········if·(mConfig.isSelectAllPrefixRangeEnabled())·{ 
44 ············this.mTetheringPrefixes.add(new·IpPrefix("172.16.0.0/12")); 
45 ············this.mTetheringPrefixes.add(new·IpPrefix("10.0.0.0/8")); 
46 ········} 
47 ····} 
48 ···· 
49 ····private·LinkAddress·chooseDownstreamAddress(IpPrefix·availablePrefixFromRange)·{ 
50 ········final·int·prefixLengthToV4NetmaskIntHTH·=·Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH(availablePrefixFromRange.getPrefixLength()); 
51 ········final·int·prefixBaseAddress·=·this.getPrefixBaseAddress(availablePrefixFromRange); 
52 ········final·int·prefixLengthToV4NetmaskIntHTH2·=·Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH(24); 
53 ········final·int·randomInt·=·this.getRandomInt(); 
54 ········final·int·n·=·~prefixLengthToV4NetmaskIntHTH; 
55 ········final·int·n2·=·randomInt·&·n·&·prefixLengthToV4NetmaskIntHTH2; 
56 ········final·int·sanitizedSubAddr·=·this.getSanitizedSubAddr(~prefixLengthToV4NetmaskIntHTH2); 
57 ········final·IpPrefix·availablePrefixFromRange2·=·this.findAvailablePrefixFromRange(n2,·n·+·1,·prefixBaseAddress,·prefixLengthToV4NetmaskIntHTH); 
58 ········if·(availablePrefixFromRange2·!=·null)·{ 
59 ············return·this.getLinkAddress(availablePrefixFromRange2,·sanitizedSubAddr); 
60 ········} 
61 ········availablePrefixFromRange·=·this.findAvailablePrefixFromRange(0,·n2,·prefixBaseAddress,·prefixLengthToV4NetmaskIntHTH); 
62 ········return·this.getLinkAddress(availablePrefixFromRange,·sanitizedSubAddr); 
63 ····} 
64 ···· 
65 ····private·IpPrefix·findAvailablePrefixFromRange(int·i,·final·int·n,·final·int·n2,·final·int·n3)·{ 
66 ········while·(i·<·n)·{ 
67 ············i·|=·n2; 
68 ············final·IpPrefix·ipPrefix·=·new·IpPrefix((InetAddress)Inet4AddressUtils.intToInet4AddressHTH(i),·24); 
69 ············final·IpPrefix·conflictPrefix·=·this.getConflictPrefix(ipPrefix); 
70 ············if·(conflictPrefix·==·null)·{ 
71 ················return·ipPrefix; 
72 ············} 
73 ············i·=·this.getNextSubPrefix(conflictPrefix,·n3); 
74 ········} 
75 ········return·null; 
76 ····} 
77 ···· 
78 ····private·IpPrefix·getConflictPrefix(final·IpPrefix·ipPrefix)·{ 
79 ········final·IpPrefix·conflictWithUpstream·=·this.getConflictWithUpstream(ipPrefix); 
80 ········if·(conflictWithUpstream·!=·null)·{ 
81 ············return·conflictWithUpstream; 
82 ········} 
83 ········return·this.getInUseDownstreamPrefix(ipPrefix); 
84 ····} 
85 ···· 
86 ····private·IpPrefix·getConflictWithUpstream(final·IpPrefix·ipPrefix)·{ 
87 ········for·(int·i·=·0;·i·<·this.mUpstreamPrefixMap.size();·++i)·{ 
88 ············for·(final·IpPrefix·ipPrefix2·:·(List)this.mUpstreamPrefixMap.valueAt(i))·{ 
89 ················if·(this.isConflictPrefix(ipPrefix,·ipPrefix2))·{ 
90 ····················return·ipPrefix2; 
91 ················} 
92 ············} 
93 ········} 
94 ········return·null; 
95 ····}35 ····}
96 ····36 ····
97 ····private·IpPrefix·getDownstreamPrefix(final·IpServer·ipServer)·{37 ····private·IpPrefix·getDownstreamPrefix(final·IpServer·ipServer)·{
 38 ········final·LinkAddress·address·=·ipServer.getAddress();
 39 ········if·(address·==·null)·{
 40 ············return·null;
98 ········return·PrefixUtils.asIpPrefix(ipServer.getAddress()); 
99 ····} 
100 ···· 
101 ····private·IpPrefix·getInUseDownstreamPrefix(final·IpPrefix·ipPrefix)·{ 
102 ········for·(int·i·=·0;·i·<·this.mCachedAddresses.size();·++i)·{ 
103 ············final·IpPrefix·ipPrefix2·=·PrefixUtils.asIpPrefix((LinkAddress)this.mCachedAddresses.valueAt(i)); 
104 ············if·(this.isConflictPrefix(ipPrefix,·ipPrefix2))·{ 
105 ················return·ipPrefix2; 
106 ············} 
107 ········} 
108 ········final·Iterator·iterator·=·this.mDownstreams.iterator(); 
109 ········while·(iterator.hasNext())·{ 
110 ············final·IpPrefix·downstreamPrefix·=·this.getDownstreamPrefix(iterator.next()); 
111 ············if·(this.isConflictPrefix(ipPrefix,·downstreamPrefix))·{ 
112 ················return·downstreamPrefix; 
113 ············} 
114 ········}41 ········}
115 ········return·null;42 ········return·PrefixUtils.asIpPrefix(address);
116 ····}43 ····}
117 ····44 ····
118 ····private·ArrayList·getIpv4Prefixes(final·List·list)·{45 ····private·ArrayList·getIpv4Prefixes(final·List·list)·{
119 ········final·ArrayList<IpPrefix>·list2·=·new·ArrayList<IpPrefix>();46 ········final·ArrayList<IpPrefix>·list2·=·new·ArrayList<IpPrefix>();
120 ········for·(final·LinkAddress·linkAddress·:·list)·{47 ········for·(final·LinkAddress·linkAddress·:·list)·{
121 ············if·(!linkAddress.isIpv4())·{48 ············if·(!linkAddress.isIpv4())·{
122 ················continue;49 ················continue;
123 ············}50 ············}
124 ············list2.add(PrefixUtils.asIpPrefix(linkAddress));51 ············list2.add(PrefixUtils.asIpPrefix(linkAddress));
125 ········}52 ········}
126 ········return·list2;53 ········return·list2;
127 ····}54 ····}
128 ····55 ····
 56 ····private·byte·getSanitizedAddressSuffix(int·length,·final·byte...·array)·{
 57 ········final·byte·b·=·(byte)(length·&·0xFF);
 58 ········length·=·array.length;
 59 ········for·(int·i·=·0;·i·<·length;·++i)·{
 60 ············if·(b·==·array[i])·{
129 ····private·LinkAddress·getLinkAddress(final·IpPrefix·ipPrefix,·final·int·n)·{ 
130 ········if·(ipPrefix·==·null)·{ 
131 ············return·null; 
132 ········} 
133 ········return·new·LinkAddress((InetAddress)Inet4AddressUtils.intToInet4AddressHTH(this.getPrefixBaseAddress(ipPrefix)·|·n),·24); 
134 ····} 
135 ···· 
136 ····private·int·getNextSubPrefix(final·IpPrefix·ipPrefix,·final·int·n)·{ 
137 ········final·int·n2·=·(this.getPrefixBaseAddress(ipPrefix)·|·~Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH(ipPrefix.getPrefixLength()))·&·~n; 
138 ········Inet4AddressUtils.prefixLengthToV4NetmaskIntHTH(24); 
139 ········return·n2·+·256; 
140 ····} 
141 ···· 
142 ····private·int·getPrefixBaseAddress(final·IpPrefix·ipPrefix)·{ 
143 ········return·Inet4AddressUtils.inet4AddressToIntHTH((Inet4Address)ipPrefix.getAddress()); 
144 ····} 
145 ···· 
146 ····private·int·getSanitizedSubAddr(int·n)·{ 
147 ········final·int·n2·=·this.getRandomInt()·&·n; 
148 ········n·=·(n2·&·0xFF); 
149 ········if·(n·!=·0·&&·n·!=·1·&&·n·!=·255)·{ 
150 ············return·n2;61 ················return·42;
 62 ············}
151 ········}63 ········}
152 ········return·(n2·&·0xFFFFFFFC)·+·2;64 ········return·b;
153 ····}65 ····}
154 ····66 ····
155 ····private·void·handleMaybePrefixConflict(final·List·list)·{67 ····private·void·handleMaybePrefixConflict(final·List·list)·{
156 ········for·(final·IpServer·ipServer·:·this.mDownstreams)·{68 ········for·(final·IpServer·ipServer·:·this.mDownstreams)·{
157 ············final·IpPrefix·downstreamPrefix·=·this.getDownstreamPrefix(ipServer);69 ············final·IpPrefix·downstreamPrefix·=·this.getDownstreamPrefix(ipServer);
 70 ············if·(downstreamPrefix·==·null)·{
 71 ················continue;
 72 ············}
158 ············final·Iterator<IpPrefix>·iterator2·=·list.iterator();73 ············final·Iterator<IpPrefix>·iterator2·=·list.iterator();
159 ············while·(iterator2.hasNext())·{74 ············while·(iterator2.hasNext())·{
160 ················if·(this.isConflictPrefix(iterator2.next(),·downstreamPrefix))·{75 ················if·(this.isConflictPrefix(iterator2.next(),·downstreamPrefix))·{
161 ····················((StateMachine)ipServer).sendMessage(113);76 ····················((StateMachine)ipServer).sendMessage(113);
162 ····················break;77 ····················break;
163 ················}78 ················}
164 ············}79 ············}
Offset 172, 117 lines modifiedOffset 87, 140 lines modified
172 ········if·(ipPrefix2.getPrefixLength()·<·ipPrefix.getPrefixLength())·{87 ········if·(ipPrefix2.getPrefixLength()·<·ipPrefix.getPrefixLength())·{
173 ············return·ipPrefix2.contains(ipPrefix.getAddress());88 ············return·ipPrefix2.contains(ipPrefix.getAddress());
174 ········}89 ········}
175 ········return·ipPrefix.contains(ipPrefix2.getAddress());90 ········return·ipPrefix.contains(ipPrefix2.getAddress());
176 ····}91 ····}
177 ····92 ····
178 ····private·boolean·isConflictWithUpstream(final·IpPrefix·ipPrefix)·{93 ····private·boolean·isConflictWithUpstream(final·IpPrefix·ipPrefix)·{
179 ········return·this.getConflictWithUpstream(ipPrefix)·!=·null;94 ········for·(int·i·=·0;·i·<·this.mUpstreamPrefixMap.size();·++i)·{
 95 ············final·Iterator·iterator·=·((List)this.mUpstreamPrefixMap.valueAt(i)).iterator();
 96 ············while·(iterator.hasNext())·{
 97 ················if·(this.isConflictPrefix(ipPrefix,·iterator.next()))·{
 98 ····················return·true;
 99 ················}
 100 ············}
 101 ········}
 102 ········return·false;
180 ····}103 ····}
181 ····104 ····
 105 ····private·boolean·isDownstreamPrefixInUse(final·IpPrefix·ipPrefix)·{
 106 ········final·Iterator·iterator·=·this.mDownstreams.iterator();
182 ····void·dump(final·IndentingPrintWriter·indentingPrintWriter)·{ 
183 ········((PrintWriter)indentingPrintWriter).println("mTetheringPrefixes:"); 
184 ········indentingPrintWriter.increaseIndent(); 
185 ········final·Iterator<IpPrefix>·iterator·=·(Iterator<IpPrefix>)this.mTetheringPrefixes.iterator(); 
186 ········while·(iterator.hasNext())·{107 ········while·(iterator.hasNext())·{
187 ············((PrintWriter)indentingPrintWriter).println(iterator.next());108 ············if·(ipPrefix.equals((Object)this.getDownstreamPrefix(iterator.next())))·{
 109 ················return·true;
 110 ············}
 111 ········}
 112 ········return·false;
 113 ····}
 114 ····
 115 ····private·void·maybeRemoveDeprectedUpstreams()·{
 116 ········if·(this.mDownstreams.isEmpty())·{
 117 ············if·(!this.mUpstreamPrefixMap.isEmpty())·{
 118 ················final·ArrayList<Network>·list·=·new·ArrayList<Network>();
 119 ················final·List<Network>·list2·=·Arrays.asList(this.mConnectivityMgr.getAllNetworks());
 120 ················for·(int·i·=·0;·i·<·this.mUpstreamPrefixMap.size();·++i)·{
 121 ····················final·Network·e·=·(Network)this.mUpstreamPrefixMap.keyAt(i);
 122 ····················if·(!list2.contains(e))·{
 123 ························list.add(e);
 124 ····················}
 125 ················}
 126 ················this.mUpstreamPrefixMap.removeAll((Collection)list);
 127 ············}
188 ········}128 ········}
 129 ····}
 130 ····
 131 ····void·dump(final·IndentingPrintWriter·indentingPrintWriter)·{
189 ········indentingPrintWriter.decreaseIndent();132 ········indentingPrintWriter.decreaseIndent();
190 ········((PrintWriter)indentingPrintWriter).println("mUpstreamPrefixMap:");133 ········((PrintWriter)indentingPrintWriter).println("mUpstreamPrefixMap:");
191 ········indentingPrintWriter.increaseIndent();134 ········indentingPrintWriter.increaseIndent();
192 ········int·i·=·0; 
193 ········int·n·=·0;135 ········int·n·=·0;
194 ········String·str;136 ········String·s;
195 ········while·(true)·{137 ········while·(true)·{
196 ············final·int·size·=·this.mUpstreamPrefixMap.size();138 ············final·int·size·=·this.mUpstreamPrefixMap.size();
197 ············str·=·"·-·";139 ············s·=·"·-·";
198 ············if·(n·>=·size)·{140 ············if·(n·>=·size)·{
199 ················break;141 ················break;
200 ············}142 ············}
201 ············final·StringBuilder·sb·=·new·StringBuilder();143 ············final·StringBuilder·sb·=·new·StringBuilder();
202 ············sb.append(this.mUpstreamPrefixMap.keyAt(n));144 ············sb.append(this.mUpstreamPrefixMap.keyAt(n));
203 ············sb.append(str);145 ············sb.append(s);
204 ············sb.append(this.mUpstreamPrefixMap.valueAt(n));146 ············sb.append(this.mUpstreamPrefixMap.valueAt(n));
205 ············((PrintWriter)indentingPrintWriter).println(sb.toString());147 ············((PrintWriter)indentingPrintWriter).println(sb.toString());
206 ············++n;148 ············++n;
207 ········}149 ········}
208 ········indentingPrintWriter.decreaseIndent();150 ········indentingPrintWriter.decreaseIndent();
209 ········((PrintWriter)indentingPrintWriter).println("mDownstreams:");151 ········((PrintWriter)indentingPrintWriter).println("mDownstreams:");
210 ········indentingPrintWriter.increaseIndent();152 ········indentingPrintWriter.increaseIndent();
211 ········for·(final·IpServer·ipServer·:·this.mDownstreams)·{153 ········for·(final·IpServer·ipServer·:·this.mDownstreams)·{
212 ············final·StringBuilder·sb2·=·new·StringBuilder();154 ············final·StringBuilder·sb2·=·new·StringBuilder();
213 ············sb2.append(ipServer.interfaceType());155 ············sb2.append(ipServer.interfaceType());
214 ············sb2.append(str);156 ············sb2.append(s);
215 ············sb2.append(ipServer.getAddress());157 ············sb2.append(ipServer.getAddress());
216 ············((PrintWriter)indentingPrintWriter).println(sb2.toString());158 ············((PrintWriter)indentingPrintWriter).println(sb2.toString());
217 ········}159 ········}
218 ········indentingPrintWriter.decreaseIndent();160 ········indentingPrintWriter.decreaseIndent();
219 ········((PrintWriter)indentingPrintWriter).println("mCachedAddresses:"); 
220 ········indentingPrintWriter.increaseIndent(); 
221 ········while·(i·<·this.mCachedAddresses.size())·{ 
222 ············final·StringBuilder·sb3·=·new·StringBuilder(); 
223 ············sb3.append(this.mCachedAddresses.keyAt(i)); 
224 ············sb3.append(str); 
225 ············sb3.append(this.mCachedAddresses.valueAt(i)); 
226 ············((PrintWriter)indentingPrintWriter).println(sb3.toString()); 
227 ············++i; 
228 ········} 
229 ········indentingPrintWriter.decreaseIndent(); 
230 ····}161 ····}
231 ····162 ····
232 ····public·int·getRandomInt()·{163 ····public·int·getRandomSubAddr()·{
233 ········return·new·Random().nextInt();164 ········return·new·Random().nextInt()·&·(char)(-1);
234 ····} 
235 ···· 
236 ····public·void·maybeRemoveDeprecatedUpstreams()·{ 
237 ········if·(this.mUpstreamPrefixMap.isEmpty())·{ 
238 ············return; 
239 ········} 
240 ········final·HashSet·set·=·new·HashSet(this.mUpstreamPrefixMap.keySet()); 
241 ········set.removeAll(Arrays.asList(this.mConnectivityMgr.getAllNetworks())); 
242 ········this.mUpstreamPrefixMap.removeAll((Collection)set); 
243 ····}165 ····}
244 ····166 ····
245 ····public·void·releaseDownstream(final·IpServer·ipServer)·{167 ····public·void·releaseDownstream(final·IpServer·ipServer)·{
246 ········this.mDownstreams.remove((Object)ipServer);168 ········this.mDownstreams.remove((Object)ipServer);
247 ····}169 ····}
248 ····170 ····
249 ····public·void·removeUpstreamPrefix(final·Network·network)·{171 ····public·void·removeUpstreamPrefix(final·Network·network)·{
250 ········this.mUpstreamPrefixMap.remove((Object)network);172 ········this.mUpstreamPrefixMap.remove((Object)network);
251 ····}173 ····}
252 ····174 ····
253 ····public·LinkAddress·requestDownstreamAddress(final·IpServer·ipServer,·final·boolean·b)·{175 ····public·LinkAddress·requestDownstreamAddress(final·IpServer·ipServer)·{
254 ········if·(this.mConfig.shouldEnableWifiP2pDedicatedIp()·&&·ipServer.interfaceType()·==·3)·{ 
255 ············return·new·LinkAddress("192.168.49.1/24"); 
256 ········} 
257 ········final·LinkAddress·linkAddress·=·(LinkAddress)this.mCachedAddresses.get(ipServer.interfaceType()); 
258 ········if·(b·&&·linkAddress·!=·null·&&·!this.isConflictWithUpstream(PrefixUtils.asIpPrefix(linkAddress)))·{ 
259 ············this.mDownstreams.add((Object)ipServer); 
260 ············return·linkAddress; 
261 ········} 
262 ········final·Iterator<IpPrefix>·iterator·=·this.mTetheringPrefixes.iterator(); 
263 ········while·(iterator.hasNext())·{ 
264 ············final·LinkAddress·chooseDownstreamAddress·=·this.chooseDownstreamAddress(iterator.next()); 
265 ············if·(chooseDownstreamAddress·!=·null)·{176 ········this.maybeRemoveDeprectedUpstreams();
 177 ········final·byte[]·rawAddress·=·this.mTetheringPrefix.getRawAddress();
 178 ········final·int·randomSubAddr·=·this.getRandomSubAddr();
 179 ········final·int·n·=·randomSubAddr·>>·8·&·0xFF;
 180 ········final·int·n2·=·3;
 181 ········final·byte[]·array2;
 182 ········final·byte[]·array·=·array2·=·new·byte[n2];
 183 ········array2[0]·=·0;
 184 ········array2[1]·=·1;
 185 ········array2[2]·=·-1;
 186 ········rawAddress[n2]·=·this.getSanitizedAddressSuffix(randomSubAddr,·array);
 187 ········int·i·=·0;
 188 ········while·(i·<·256)·{
 189 ············final·int·n3·=·n·+·i·&·0xFF;
 190 ············Label_0166:·{
 191 ················if·(n3·==·44)·{
 192 ····················break·Label_0166;
 193 ················}
 194 ················rawAddress[2]·=·(byte)n3;
 195 ················try·{
 196 ····················final·InetAddress·byAddress·=·InetAddress.getByAddress(rawAddress);
 197 ····················final·int·n4·=·24;
 198 ····················final·IpPrefix·ipPrefix·=·new·IpPrefix(byAddress,·n4);
 199 ····················if·(!this.isDownstreamPrefixInUse(ipPrefix))·{
 200 ························if·(!this.isConflictWithUpstream(ipPrefix))·{
266 ················this.mDownstreams.add((Object)ipServer);201 ····························this.mDownstreams.add((Object)ipServer);
267 ················this.mCachedAddresses.put(ipServer.interfaceType(),·(Object)chooseDownstreamAddress); 
268 ················return·chooseDownstreamAddress;202 ····························return·new·LinkAddress(byAddress,·n4);
 203 ························}
 204 ····················}
 205 ····················++i;
 206 ····················continue;
 207 ················}
 208 ················catch·(UnknownHostException·cause)·{
 209 ····················throw·new·IllegalStateException("Invalid·address,·shouldn't·happen.",·cause);
 210 ················}
269 ············}211 ············}
 212 ············break;
270 ········}213 ········}
271 ········return·null;214 ········return·null;
272 ····}215 ····}
273 ····216 ····
 217 ····public·void·updateUpstreamPrefix(final·Network·network,·final·LinkProperties·linkProperties)·{
274 ····public·void·updateUpstreamPrefix(final·UpstreamNetworkState·upstreamNetworkState)·{ 
275 ········final·NetworkCapabilities·networkCapabilities·=·upstreamNetworkState.networkCapabilities; 
276 ········if·(networkCapabilities·!=·null·&&·networkCapabilities.hasTransport(4))·{ 
277 ············this.removeUpstreamPrefix(upstreamNetworkState.network); 
278 ············return; 
279 ········} 
280 ········final·ArrayList·ipv4Prefixes·=·this.getIpv4Prefixes(upstreamNetworkState.linkProperties.getAllLinkAddresses());218 ········final·ArrayList·ipv4Prefixes·=·this.getIpv4Prefixes(linkProperties.getAllLinkAddresses());
281 ········if·(ipv4Prefixes.isEmpty())·{219 ········if·(ipv4Prefixes.isEmpty())·{
282 ············this.removeUpstreamPrefix(upstreamNetworkState.network);220 ············this.removeUpstreamPrefix(network);
283 ············return;221 ············return;
284 ········}222 ········}
285 ········this.mUpstreamPrefixMap.put((Object)upstreamNetworkState.network,·(Object)ipv4Prefixes);223 ········this.mUpstreamPrefixMap.put((Object)network,·(Object)ipv4Prefixes);
286 ········this.handleMaybePrefixConflict(ipv4Prefixes);224 ········this.handleMaybePrefixConflict(ipv4Prefixes);
287 ····}225 ····}
288 }226 }