blob: 76a781dd7dafc24daf44b54862f7470b42478a30 [file] [log] [blame]
Hugo Benichi647c86d2016-06-07 15:35:16 +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 android.net.metrics;
18
Hugo Benichi647c86d2016-06-07 15:35:16 +090019import android.os.Parcel;
20import android.os.Parcelable;
21
22/**
Erik Kline8d1fe542018-03-12 23:18:58 +090023 * An event logged for an interface with APF capabilities when its IpClient state machine exits.
Hugo Benichi647c86d2016-06-07 15:35:16 +090024 * {@hide}
25 */
Hugo Benichi647c86d2016-06-07 15:35:16 +090026public final class ApfStats implements Parcelable {
27
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090028 /** time interval in milliseconds these stastistics covers. */
29 public long durationMs;
30 /** number of received RAs. */
31 public int receivedRas;
32 /** number of received RAs matching a known RA. */
33 public int matchingRas;
34 /** number of received RAs ignored due to the MAX_RAS limit. */
35 public int droppedRas;
36 /** number of received RAs with a minimum lifetime of 0. */
37 public int zeroLifetimeRas;
38 /** number of received RAs that could not be parsed. */
39 public int parseErrors;
40 /** number of APF program updates from receiving RAs.. */
41 public int programUpdates;
42 /** total number of APF program updates. */
43 public int programUpdatesAll;
44 /** number of APF program updates from allowing multicast traffic. */
45 public int programUpdatesAllowingMulticast;
46 /** maximum APF program size advertised by hardware. */
47 public int maxProgramSize;
Hugo Benichi647c86d2016-06-07 15:35:16 +090048
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090049 public ApfStats() {
Hugo Benichi647c86d2016-06-07 15:35:16 +090050 }
51
52 private ApfStats(Parcel in) {
53 this.durationMs = in.readLong();
54 this.receivedRas = in.readInt();
55 this.matchingRas = in.readInt();
56 this.droppedRas = in.readInt();
57 this.zeroLifetimeRas = in.readInt();
58 this.parseErrors = in.readInt();
59 this.programUpdates = in.readInt();
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090060 this.programUpdatesAll = in.readInt();
61 this.programUpdatesAllowingMulticast = in.readInt();
Hugo Benichi647c86d2016-06-07 15:35:16 +090062 this.maxProgramSize = in.readInt();
63 }
64
65 @Override
66 public void writeToParcel(Parcel out, int flags) {
67 out.writeLong(durationMs);
68 out.writeInt(receivedRas);
69 out.writeInt(matchingRas);
70 out.writeInt(droppedRas);
71 out.writeInt(zeroLifetimeRas);
72 out.writeInt(parseErrors);
73 out.writeInt(programUpdates);
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090074 out.writeInt(programUpdatesAll);
75 out.writeInt(programUpdatesAllowingMulticast);
Hugo Benichi647c86d2016-06-07 15:35:16 +090076 out.writeInt(maxProgramSize);
77 }
78
79 @Override
80 public int describeContents() {
81 return 0;
82 }
83
84 @Override
85 public String toString() {
86 return new StringBuilder("ApfStats(")
87 .append(String.format("%dms ", durationMs))
88 .append(String.format("%dB RA: {", maxProgramSize))
89 .append(String.format("%d received, ", receivedRas))
90 .append(String.format("%d matching, ", matchingRas))
91 .append(String.format("%d dropped, ", droppedRas))
92 .append(String.format("%d zero lifetime, ", zeroLifetimeRas))
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090093 .append(String.format("%d parse errors}, ", parseErrors))
94 .append(String.format("updates: {all: %d, RAs: %d, allow multicast: %d})",
95 programUpdatesAll, programUpdates, programUpdatesAllowingMulticast))
Hugo Benichi647c86d2016-06-07 15:35:16 +090096 .toString();
97 }
98
99 public static final Parcelable.Creator<ApfStats> CREATOR = new Parcelable.Creator<ApfStats>() {
100 public ApfStats createFromParcel(Parcel in) {
101 return new ApfStats(in);
102 }
103
104 public ApfStats[] newArray(int size) {
105 return new ApfStats[size];
106 }
107 };
108}