blob: bb2a35c5866736bbe58e5a6fc0e799cd785b0867 [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
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010019import android.annotation.UnsupportedAppUsage;
Hugo Benichi647c86d2016-06-07 15:35:16 +090020import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
Erik Kline8d1fe542018-03-12 23:18:58 +090024 * An event logged for an interface with APF capabilities when its IpClient state machine exits.
Hugo Benichi647c86d2016-06-07 15:35:16 +090025 * {@hide}
26 */
Hugo Benichi647c86d2016-06-07 15:35:16 +090027public final class ApfStats implements Parcelable {
28
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090029 /** time interval in milliseconds these stastistics covers. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010030 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090031 public long durationMs;
32 /** number of received RAs. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010033 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090034 public int receivedRas;
35 /** number of received RAs matching a known RA. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010036 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090037 public int matchingRas;
38 /** number of received RAs ignored due to the MAX_RAS limit. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010039 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090040 public int droppedRas;
41 /** number of received RAs with a minimum lifetime of 0. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010042 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090043 public int zeroLifetimeRas;
44 /** number of received RAs that could not be parsed. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010045 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090046 public int parseErrors;
47 /** number of APF program updates from receiving RAs.. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010048 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090049 public int programUpdates;
50 /** total number of APF program updates. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010051 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090052 public int programUpdatesAll;
53 /** number of APF program updates from allowing multicast traffic. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010054 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090055 public int programUpdatesAllowingMulticast;
56 /** maximum APF program size advertised by hardware. */
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010057 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090058 public int maxProgramSize;
Hugo Benichi647c86d2016-06-07 15:35:16 +090059
Mathew Inwoodfa3a7462018-08-08 14:52:47 +010060 @UnsupportedAppUsage
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090061 public ApfStats() {
Hugo Benichi647c86d2016-06-07 15:35:16 +090062 }
63
64 private ApfStats(Parcel in) {
65 this.durationMs = in.readLong();
66 this.receivedRas = in.readInt();
67 this.matchingRas = in.readInt();
68 this.droppedRas = in.readInt();
69 this.zeroLifetimeRas = in.readInt();
70 this.parseErrors = in.readInt();
71 this.programUpdates = in.readInt();
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090072 this.programUpdatesAll = in.readInt();
73 this.programUpdatesAllowingMulticast = in.readInt();
Hugo Benichi647c86d2016-06-07 15:35:16 +090074 this.maxProgramSize = in.readInt();
75 }
76
77 @Override
78 public void writeToParcel(Parcel out, int flags) {
79 out.writeLong(durationMs);
80 out.writeInt(receivedRas);
81 out.writeInt(matchingRas);
82 out.writeInt(droppedRas);
83 out.writeInt(zeroLifetimeRas);
84 out.writeInt(parseErrors);
85 out.writeInt(programUpdates);
Hugo Benichi22d9b2d2017-02-22 13:02:27 +090086 out.writeInt(programUpdatesAll);
87 out.writeInt(programUpdatesAllowingMulticast);
Hugo Benichi647c86d2016-06-07 15:35:16 +090088 out.writeInt(maxProgramSize);
89 }
90
91 @Override
92 public int describeContents() {
93 return 0;
94 }
95
96 @Override
97 public String toString() {
98 return new StringBuilder("ApfStats(")
99 .append(String.format("%dms ", durationMs))
100 .append(String.format("%dB RA: {", maxProgramSize))
101 .append(String.format("%d received, ", receivedRas))
102 .append(String.format("%d matching, ", matchingRas))
103 .append(String.format("%d dropped, ", droppedRas))
104 .append(String.format("%d zero lifetime, ", zeroLifetimeRas))
Hugo Benichi22d9b2d2017-02-22 13:02:27 +0900105 .append(String.format("%d parse errors}, ", parseErrors))
106 .append(String.format("updates: {all: %d, RAs: %d, allow multicast: %d})",
107 programUpdatesAll, programUpdates, programUpdatesAllowingMulticast))
Hugo Benichi647c86d2016-06-07 15:35:16 +0900108 .toString();
109 }
110
111 public static final Parcelable.Creator<ApfStats> CREATOR = new Parcelable.Creator<ApfStats>() {
112 public ApfStats createFromParcel(Parcel in) {
113 return new ApfStats(in);
114 }
115
116 public ApfStats[] newArray(int size) {
117 return new ApfStats[size];
118 }
119 };
120}