blob: 8451e539a7f677beb71c293a1c5d0d321c4fbbed [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
19import android.annotation.SystemApi;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23/**
24 * An event logged for an interface with APF capabilities when its IpManager state machine exits.
25 * {@hide}
26 */
27@SystemApi
28public final class ApfStats implements Parcelable {
29
30 public final long durationMs; // time interval in milliseconds these stastistics covers
31 public final int receivedRas; // number of received RAs
32 public final int matchingRas; // number of received RAs matching a known RA
33 public final int droppedRas; // number of received RAs ignored due to the MAX_RAS limit
34 public final int zeroLifetimeRas; // number of received RAs with a minimum lifetime of 0
35 public final int parseErrors; // number of received RAs that could not be parsed
36 public final int programUpdates; // number of APF program updates
37 public final int maxProgramSize; // maximum APF program size advertised by hardware
38
39 /** {@hide} */
40 public ApfStats(long durationMs, int receivedRas, int matchingRas, int droppedRas,
41 int zeroLifetimeRas, int parseErrors, int programUpdates, int maxProgramSize) {
42 this.durationMs = durationMs;
43 this.receivedRas = receivedRas;
44 this.matchingRas = matchingRas;
45 this.droppedRas = droppedRas;
46 this.zeroLifetimeRas = zeroLifetimeRas;
47 this.parseErrors = parseErrors;
48 this.programUpdates = programUpdates;
49 this.maxProgramSize = maxProgramSize;
50 }
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();
60 this.maxProgramSize = in.readInt();
61 }
62
63 @Override
64 public void writeToParcel(Parcel out, int flags) {
65 out.writeLong(durationMs);
66 out.writeInt(receivedRas);
67 out.writeInt(matchingRas);
68 out.writeInt(droppedRas);
69 out.writeInt(zeroLifetimeRas);
70 out.writeInt(parseErrors);
71 out.writeInt(programUpdates);
72 out.writeInt(maxProgramSize);
73 }
74
75 @Override
76 public int describeContents() {
77 return 0;
78 }
79
80 @Override
81 public String toString() {
82 return new StringBuilder("ApfStats(")
83 .append(String.format("%dms ", durationMs))
84 .append(String.format("%dB RA: {", maxProgramSize))
85 .append(String.format("%d received, ", receivedRas))
86 .append(String.format("%d matching, ", matchingRas))
87 .append(String.format("%d dropped, ", droppedRas))
88 .append(String.format("%d zero lifetime, ", zeroLifetimeRas))
89 .append(String.format("%d parse errors, ", parseErrors))
90 .append(String.format("%d program updates})", programUpdates))
91 .toString();
92 }
93
94 public static final Parcelable.Creator<ApfStats> CREATOR = new Parcelable.Creator<ApfStats>() {
95 public ApfStats createFromParcel(Parcel in) {
96 return new ApfStats(in);
97 }
98
99 public ApfStats[] newArray(int size) {
100 return new ApfStats[size];
101 }
102 };
103}