blob: 67e72167faa7bc2b61c0b171368b4189ec15bea3 [file] [log] [blame]
Hugo Benichi50a84c62016-09-02 09:00:59 +09001/*
2 * Copyright (C) 2016 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
17package com.android.server.connectivity;
18
Hugo Benichi73fd4d12017-03-15 23:05:01 +090019import static android.net.NetworkCapabilities.MAX_TRANSPORT;
20import static android.net.NetworkCapabilities.TRANSPORT_BLUETOOTH;
21import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
22import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET;
Hugo Benichi27a51172017-07-18 11:35:18 +090023import static android.net.NetworkCapabilities.TRANSPORT_LOWPAN;
Hugo Benichi73fd4d12017-03-15 23:05:01 +090024import static android.net.NetworkCapabilities.TRANSPORT_VPN;
25import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
26import static android.net.NetworkCapabilities.TRANSPORT_WIFI_AWARE;
Hugo Benichi73fd4d12017-03-15 23:05:01 +090027
Hugo Benichi50a84c62016-09-02 09:00:59 +090028import android.net.ConnectivityMetricsEvent;
29import android.net.metrics.ApfProgramEvent;
30import android.net.metrics.ApfStats;
31import android.net.metrics.DefaultNetworkEvent;
32import android.net.metrics.DhcpClientEvent;
33import android.net.metrics.DhcpErrorEvent;
34import android.net.metrics.DnsEvent;
Hugo Benichi5eb90532017-03-23 18:38:22 +090035import android.net.metrics.ConnectStats;
Hugo Benichi50a84c62016-09-02 09:00:59 +090036import android.net.metrics.IpManagerEvent;
37import android.net.metrics.IpReachabilityEvent;
38import android.net.metrics.NetworkEvent;
39import android.net.metrics.RaEvent;
40import android.net.metrics.ValidationProbeEvent;
Hugo Benichi60c9f632017-09-05 13:34:48 +090041import android.net.metrics.WakeupStats;
Hugo Benichi50a84c62016-09-02 09:00:59 +090042import android.os.Parcelable;
Hugo Benichi73fd4d12017-03-15 23:05:01 +090043import android.util.SparseArray;
Hugo Benichi5eb90532017-03-23 18:38:22 +090044import android.util.SparseIntArray;
Tamas Berghammer383db5eb2016-06-22 15:21:38 +010045import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass;
Hugo Benichi5eb90532017-03-23 18:38:22 +090046import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityEvent;
47import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.IpConnectivityLog;
48import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.NetworkId;
49import com.android.server.connectivity.metrics.nano.IpConnectivityLogClass.Pair;
Hugo Benichi50a84c62016-09-02 09:00:59 +090050import java.io.IOException;
51import java.util.ArrayList;
52import java.util.List;
53
Hugo Benichi50a84c62016-09-02 09:00:59 +090054
55/** {@hide} */
56final public class IpConnectivityEventBuilder {
57 private IpConnectivityEventBuilder() {
58 }
59
Hugo Benichi0d4a3982016-11-25 11:24:22 +090060 public static byte[] serialize(int dropped, List<IpConnectivityEvent> events)
Hugo Benichi50a84c62016-09-02 09:00:59 +090061 throws IOException {
62 final IpConnectivityLog log = new IpConnectivityLog();
Hugo Benichi0d4a3982016-11-25 11:24:22 +090063 log.events = events.toArray(new IpConnectivityEvent[events.size()]);
Hugo Benichi50a84c62016-09-02 09:00:59 +090064 log.droppedEvents = dropped;
Hugo Benichid680d4c2016-10-13 13:16:16 +090065 if ((log.events.length > 0) || (dropped > 0)) {
66 // Only write version number if log has some information at all.
67 log.version = IpConnectivityMetrics.VERSION;
68 }
Hugo Benichi50a84c62016-09-02 09:00:59 +090069 return IpConnectivityLog.toByteArray(log);
70 }
71
Hugo Benichi0d4a3982016-11-25 11:24:22 +090072 public static List<IpConnectivityEvent> toProto(List<ConnectivityMetricsEvent> eventsIn) {
Hugo Benichi50a84c62016-09-02 09:00:59 +090073 final ArrayList<IpConnectivityEvent> eventsOut = new ArrayList<>(eventsIn.size());
74 for (ConnectivityMetricsEvent in : eventsIn) {
75 final IpConnectivityEvent out = toProto(in);
76 if (out == null) {
77 continue;
78 }
79 eventsOut.add(out);
80 }
Hugo Benichi0d4a3982016-11-25 11:24:22 +090081 return eventsOut;
Hugo Benichi50a84c62016-09-02 09:00:59 +090082 }
83
84 public static IpConnectivityEvent toProto(ConnectivityMetricsEvent ev) {
Hugo Benichi5eb90532017-03-23 18:38:22 +090085 final IpConnectivityEvent out = buildEvent(ev.netId, ev.transports, ev.ifname);
86 out.timeMs = ev.timestamp;
Hugo Benichi50a84c62016-09-02 09:00:59 +090087 if (!setEvent(out, ev.data)) {
88 return null;
89 }
Hugo Benichi50a84c62016-09-02 09:00:59 +090090 return out;
91 }
92
Hugo Benichi5eb90532017-03-23 18:38:22 +090093 public static IpConnectivityEvent toProto(ConnectStats in) {
94 IpConnectivityLogClass.ConnectStatistics stats =
95 new IpConnectivityLogClass.ConnectStatistics();
96 stats.connectCount = in.connectCount;
97 stats.connectBlockingCount = in.connectBlockingCount;
98 stats.ipv6AddrCount = in.ipv6ConnectCount;
99 stats.latenciesMs = in.latencies.toArray();
100 stats.errnosCounters = toPairArray(in.errnos);
101 final IpConnectivityEvent out = buildEvent(in.netId, in.transports, null);
102 out.setConnectStatistics(stats);
103 return out;
104 }
105
106
Hugo Benichi2a5cfb92017-03-22 22:21:44 +0900107 public static IpConnectivityEvent toProto(DnsEvent in) {
Hugo Benichi2a5cfb92017-03-22 22:21:44 +0900108 IpConnectivityLogClass.DNSLookupBatch dnsLookupBatch =
109 new IpConnectivityLogClass.DNSLookupBatch();
110 in.resize(in.eventCount);
111 dnsLookupBatch.eventTypes = bytesToInts(in.eventTypes);
112 dnsLookupBatch.returnCodes = bytesToInts(in.returnCodes);
113 dnsLookupBatch.latenciesMs = in.latenciesMs;
Hugo Benichi5eb90532017-03-23 18:38:22 +0900114 final IpConnectivityEvent out = buildEvent(in.netId, in.transports, null);
Hugo Benichi2a5cfb92017-03-22 22:21:44 +0900115 out.setDnsLookupBatch(dnsLookupBatch);
Hugo Benichi2a5cfb92017-03-22 22:21:44 +0900116 return out;
117 }
118
Hugo Benichi60c9f632017-09-05 13:34:48 +0900119 public static IpConnectivityEvent toProto(WakeupStats in) {
120 IpConnectivityLogClass.WakeupStats wakeupStats =
121 new IpConnectivityLogClass.WakeupStats();
122 in.updateDuration();
123 wakeupStats.durationSec = in.durationSec;
124 wakeupStats.totalWakeups = in.totalWakeups;
125 wakeupStats.rootWakeups = in.rootWakeups;
126 wakeupStats.systemWakeups = in.systemWakeups;
127 wakeupStats.nonApplicationWakeups = in.nonApplicationWakeups;
128 wakeupStats.applicationWakeups = in.applicationWakeups;
Hugo Benichi175b5742017-09-19 13:15:26 +0900129 wakeupStats.noUidWakeups = in.noUidWakeups;
Hugo Benichi60c9f632017-09-05 13:34:48 +0900130 final IpConnectivityEvent out = buildEvent(0, 0, in.iface);
131 out.setWakeupStats(wakeupStats);
132 return out;
133 }
134
Hugo Benichi5eb90532017-03-23 18:38:22 +0900135 private static IpConnectivityEvent buildEvent(int netId, long transports, String ifname) {
136 final IpConnectivityEvent ev = new IpConnectivityEvent();
137 ev.networkId = netId;
138 ev.transports = transports;
139 if (ifname != null) {
140 ev.ifName = ifname;
141 }
142 inferLinkLayer(ev);
143 return ev;
144 }
145
Hugo Benichi50a84c62016-09-02 09:00:59 +0900146 private static boolean setEvent(IpConnectivityEvent out, Parcelable in) {
147 if (in instanceof DhcpErrorEvent) {
148 setDhcpErrorEvent(out, (DhcpErrorEvent) in);
149 return true;
150 }
151
152 if (in instanceof DhcpClientEvent) {
153 setDhcpClientEvent(out, (DhcpClientEvent) in);
154 return true;
155 }
156
Hugo Benichi50a84c62016-09-02 09:00:59 +0900157 if (in instanceof IpManagerEvent) {
158 setIpManagerEvent(out, (IpManagerEvent) in);
159 return true;
160 }
161
162 if (in instanceof IpReachabilityEvent) {
163 setIpReachabilityEvent(out, (IpReachabilityEvent) in);
164 return true;
165 }
166
167 if (in instanceof DefaultNetworkEvent) {
168 setDefaultNetworkEvent(out, (DefaultNetworkEvent) in);
169 return true;
170 }
171
172 if (in instanceof NetworkEvent) {
173 setNetworkEvent(out, (NetworkEvent) in);
174 return true;
175 }
176
177 if (in instanceof ValidationProbeEvent) {
178 setValidationProbeEvent(out, (ValidationProbeEvent) in);
179 return true;
180 }
181
182 if (in instanceof ApfProgramEvent) {
183 setApfProgramEvent(out, (ApfProgramEvent) in);
184 return true;
185 }
186
187 if (in instanceof ApfStats) {
188 setApfStats(out, (ApfStats) in);
189 return true;
190 }
191
192 if (in instanceof RaEvent) {
193 setRaEvent(out, (RaEvent) in);
194 return true;
195 }
196
197 return false;
198 }
199
200 private static void setDhcpErrorEvent(IpConnectivityEvent out, DhcpErrorEvent in) {
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100201 IpConnectivityLogClass.DHCPEvent dhcpEvent = new IpConnectivityLogClass.DHCPEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100202 dhcpEvent.setErrorCode(in.errorCode);
203 out.setDhcpEvent(dhcpEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900204 }
205
206 private static void setDhcpClientEvent(IpConnectivityEvent out, DhcpClientEvent in) {
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100207 IpConnectivityLogClass.DHCPEvent dhcpEvent = new IpConnectivityLogClass.DHCPEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100208 dhcpEvent.setStateTransition(in.msg);
209 dhcpEvent.durationMs = in.durationMs;
210 out.setDhcpEvent(dhcpEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900211 }
212
Hugo Benichi50a84c62016-09-02 09:00:59 +0900213 private static void setIpManagerEvent(IpConnectivityEvent out, IpManagerEvent in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900214 IpConnectivityLogClass.IpProvisioningEvent ipProvisioningEvent =
215 new IpConnectivityLogClass.IpProvisioningEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100216 ipProvisioningEvent.eventType = in.eventType;
217 ipProvisioningEvent.latencyMs = (int) in.durationMs;
218 out.setIpProvisioningEvent(ipProvisioningEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900219 }
220
221 private static void setIpReachabilityEvent(IpConnectivityEvent out, IpReachabilityEvent in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900222 IpConnectivityLogClass.IpReachabilityEvent ipReachabilityEvent =
223 new IpConnectivityLogClass.IpReachabilityEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100224 ipReachabilityEvent.eventType = in.eventType;
225 out.setIpReachabilityEvent(ipReachabilityEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900226 }
227
228 private static void setDefaultNetworkEvent(IpConnectivityEvent out, DefaultNetworkEvent in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900229 IpConnectivityLogClass.DefaultNetworkEvent defaultNetworkEvent =
230 new IpConnectivityLogClass.DefaultNetworkEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100231 defaultNetworkEvent.networkId = netIdOf(in.netId);
232 defaultNetworkEvent.previousNetworkId = netIdOf(in.prevNetId);
233 defaultNetworkEvent.transportTypes = in.transportTypes;
234 defaultNetworkEvent.previousNetworkIpSupport = ipSupportOf(in);
235 out.setDefaultNetworkEvent(defaultNetworkEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900236 }
237
238 private static void setNetworkEvent(IpConnectivityEvent out, NetworkEvent in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900239 IpConnectivityLogClass.NetworkEvent networkEvent =
240 new IpConnectivityLogClass.NetworkEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100241 networkEvent.networkId = netIdOf(in.netId);
242 networkEvent.eventType = in.eventType;
243 networkEvent.latencyMs = (int) in.durationMs;
244 out.setNetworkEvent(networkEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900245 }
246
247 private static void setValidationProbeEvent(IpConnectivityEvent out, ValidationProbeEvent in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900248 IpConnectivityLogClass.ValidationProbeEvent validationProbeEvent =
249 new IpConnectivityLogClass.ValidationProbeEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100250 validationProbeEvent.latencyMs = (int) in.durationMs;
251 validationProbeEvent.probeType = in.probeType;
252 validationProbeEvent.probeResult = in.returnCode;
253 out.setValidationProbeEvent(validationProbeEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900254 }
255
256 private static void setApfProgramEvent(IpConnectivityEvent out, ApfProgramEvent in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900257 IpConnectivityLogClass.ApfProgramEvent apfProgramEvent =
258 new IpConnectivityLogClass.ApfProgramEvent();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100259 apfProgramEvent.lifetime = in.lifetime;
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900260 apfProgramEvent.effectiveLifetime = in.actualLifetime;
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100261 apfProgramEvent.filteredRas = in.filteredRas;
262 apfProgramEvent.currentRas = in.currentRas;
263 apfProgramEvent.programLength = in.programLength;
Hugo Benichi50a84c62016-09-02 09:00:59 +0900264 if (isBitSet(in.flags, ApfProgramEvent.FLAG_MULTICAST_FILTER_ON)) {
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100265 apfProgramEvent.dropMulticast = true;
Hugo Benichi50a84c62016-09-02 09:00:59 +0900266 }
267 if (isBitSet(in.flags, ApfProgramEvent.FLAG_HAS_IPV4_ADDRESS)) {
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100268 apfProgramEvent.hasIpv4Addr = true;
Hugo Benichi50a84c62016-09-02 09:00:59 +0900269 }
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100270 out.setApfProgramEvent(apfProgramEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900271 }
272
273 private static void setApfStats(IpConnectivityEvent out, ApfStats in) {
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900274 IpConnectivityLogClass.ApfStatistics apfStatistics =
275 new IpConnectivityLogClass.ApfStatistics();
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100276 apfStatistics.durationMs = in.durationMs;
277 apfStatistics.receivedRas = in.receivedRas;
278 apfStatistics.matchingRas = in.matchingRas;
279 apfStatistics.droppedRas = in.droppedRas;
280 apfStatistics.zeroLifetimeRas = in.zeroLifetimeRas;
281 apfStatistics.parseErrors = in.parseErrors;
282 apfStatistics.programUpdates = in.programUpdates;
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900283 apfStatistics.programUpdatesAll = in.programUpdatesAll;
284 apfStatistics.programUpdatesAllowingMulticast = in.programUpdatesAllowingMulticast;
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100285 apfStatistics.maxProgramSize = in.maxProgramSize;
286 out.setApfStatistics(apfStatistics);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900287 }
288
289 private static void setRaEvent(IpConnectivityEvent out, RaEvent in) {
Tamas Berghammer383db5eb2016-06-22 15:21:38 +0100290 IpConnectivityLogClass.RaEvent raEvent = new IpConnectivityLogClass.RaEvent();
291 raEvent.routerLifetime = in.routerLifetime;
292 raEvent.prefixValidLifetime = in.prefixValidLifetime;
293 raEvent.prefixPreferredLifetime = in.prefixPreferredLifetime;
294 raEvent.routeInfoLifetime = in.routeInfoLifetime;
295 raEvent.rdnssLifetime = in.rdnssLifetime;
296 raEvent.dnsslLifetime = in.dnsslLifetime;
297 out.setRaEvent(raEvent);
Hugo Benichi50a84c62016-09-02 09:00:59 +0900298 }
299
300 private static int[] bytesToInts(byte[] in) {
301 final int[] out = new int[in.length];
302 for (int i = 0; i < in.length; i++) {
303 out[i] = in[i] & 0xFF;
304 }
305 return out;
306 }
307
Hugo Benichi5eb90532017-03-23 18:38:22 +0900308 private static Pair[] toPairArray(SparseIntArray counts) {
309 final int s = counts.size();
310 Pair[] pairs = new Pair[s];
311 for (int i = 0; i < s; i++) {
312 Pair p = new Pair();
313 p.key = counts.keyAt(i);
314 p.value = counts.valueAt(i);
315 pairs[i] = p;
316 }
317 return pairs;
318 }
319
Hugo Benichi50a84c62016-09-02 09:00:59 +0900320 private static NetworkId netIdOf(int netid) {
321 final NetworkId ni = new NetworkId();
322 ni.networkId = netid;
323 return ni;
324 }
325
326 private static int ipSupportOf(DefaultNetworkEvent in) {
327 if (in.prevIPv4 && in.prevIPv6) {
328 return IpConnectivityLogClass.DefaultNetworkEvent.DUAL;
329 }
330 if (in.prevIPv6) {
331 return IpConnectivityLogClass.DefaultNetworkEvent.IPV6;
332 }
333 if (in.prevIPv4) {
334 return IpConnectivityLogClass.DefaultNetworkEvent.IPV4;
335 }
336 return IpConnectivityLogClass.DefaultNetworkEvent.NONE;
337 }
338
339 private static boolean isBitSet(int flags, int bit) {
340 return (flags & (1 << bit)) != 0;
341 }
Hugo Benichi73fd4d12017-03-15 23:05:01 +0900342
343 private static void inferLinkLayer(IpConnectivityEvent ev) {
344 int linkLayer = IpConnectivityLogClass.UNKNOWN;
345 if (ev.transports != 0) {
346 linkLayer = transportsToLinkLayer(ev.transports);
347 } else if (ev.ifName != null) {
348 linkLayer = ifnameToLinkLayer(ev.ifName);
349 }
350 if (linkLayer == IpConnectivityLogClass.UNKNOWN) {
351 return;
352 }
353 ev.linkLayer = linkLayer;
354 ev.ifName = "";
355 }
356
357 private static int transportsToLinkLayer(long transports) {
358 switch (Long.bitCount(transports)) {
359 case 0:
360 return IpConnectivityLogClass.UNKNOWN;
361 case 1:
362 int t = Long.numberOfTrailingZeros(transports);
363 return transportToLinkLayer(t);
364 default:
365 return IpConnectivityLogClass.MULTIPLE;
366 }
367 }
368
369 private static int transportToLinkLayer(int transport) {
370 if (0 <= transport && transport < TRANSPORT_LINKLAYER_MAP.length) {
371 return TRANSPORT_LINKLAYER_MAP[transport];
372 }
373 return IpConnectivityLogClass.UNKNOWN;
374 }
375
376 private static final int[] TRANSPORT_LINKLAYER_MAP = new int[MAX_TRANSPORT + 1];
377 static {
378 TRANSPORT_LINKLAYER_MAP[TRANSPORT_CELLULAR] = IpConnectivityLogClass.CELLULAR;
379 TRANSPORT_LINKLAYER_MAP[TRANSPORT_WIFI] = IpConnectivityLogClass.WIFI;
380 TRANSPORT_LINKLAYER_MAP[TRANSPORT_BLUETOOTH] = IpConnectivityLogClass.BLUETOOTH;
381 TRANSPORT_LINKLAYER_MAP[TRANSPORT_ETHERNET] = IpConnectivityLogClass.ETHERNET;
382 TRANSPORT_LINKLAYER_MAP[TRANSPORT_VPN] = IpConnectivityLogClass.UNKNOWN;
Hugo Benichi27a51172017-07-18 11:35:18 +0900383 TRANSPORT_LINKLAYER_MAP[TRANSPORT_WIFI_AWARE] = IpConnectivityLogClass.WIFI_NAN;
384 TRANSPORT_LINKLAYER_MAP[TRANSPORT_LOWPAN] = IpConnectivityLogClass.LOWPAN;
Hugo Benichi73fd4d12017-03-15 23:05:01 +0900385 };
386
387 private static int ifnameToLinkLayer(String ifname) {
388 // Do not try to catch all interface names with regexes, instead only catch patterns that
389 // are cheap to check, and otherwise fallback on postprocessing in aggregation layer.
Hugo Benichi27a51172017-07-18 11:35:18 +0900390 for (int i = 0; i < KNOWN_PREFIX; i++) {
391 String pattern = IFNAME_PREFIXES[i];
Hugo Benichi73fd4d12017-03-15 23:05:01 +0900392 if (ifname.startsWith(pattern)) {
Hugo Benichi27a51172017-07-18 11:35:18 +0900393 return IFNAME_LINKLAYERS[i];
Hugo Benichi73fd4d12017-03-15 23:05:01 +0900394 }
395 }
396 return IpConnectivityLogClass.UNKNOWN;
397 }
398
Hugo Benichi27a51172017-07-18 11:35:18 +0900399 private static final int KNOWN_PREFIX = 7;
400 private static final String[] IFNAME_PREFIXES = new String[KNOWN_PREFIX];
401 private static final int[] IFNAME_LINKLAYERS = new int[KNOWN_PREFIX];
Hugo Benichi73fd4d12017-03-15 23:05:01 +0900402 static {
Hugo Benichi27a51172017-07-18 11:35:18 +0900403 // Ordered from most likely link layer to least likely.
404 IFNAME_PREFIXES[0] = "rmnet";
405 IFNAME_LINKLAYERS[0] = IpConnectivityLogClass.CELLULAR;
406
407 IFNAME_PREFIXES[1] = "wlan";
408 IFNAME_LINKLAYERS[1] = IpConnectivityLogClass.WIFI;
409
410 IFNAME_PREFIXES[2] = "bt-pan";
411 IFNAME_LINKLAYERS[2] = IpConnectivityLogClass.BLUETOOTH;
412
413 IFNAME_PREFIXES[3] = "p2p";
414 IFNAME_LINKLAYERS[3] = IpConnectivityLogClass.WIFI_P2P;
415
416 IFNAME_PREFIXES[4] = "aware";
417 IFNAME_LINKLAYERS[4] = IpConnectivityLogClass.WIFI_NAN;
418
419 IFNAME_PREFIXES[5] = "eth";
420 IFNAME_LINKLAYERS[5] = IpConnectivityLogClass.ETHERNET;
421
422 IFNAME_PREFIXES[6] = "wpan";
423 IFNAME_LINKLAYERS[6] = IpConnectivityLogClass.LOWPAN;
Hugo Benichi73fd4d12017-03-15 23:05:01 +0900424 }
Hugo Benichi50a84c62016-09-02 09:00:59 +0900425}