• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package android.net.metrics;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * An event logged for an interface with APF capabilities when its IpManager state machine exits.
24  * {@hide}
25  */
26 public final class ApfStats implements Parcelable {
27 
28     /** 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;
48 
ApfStats()49     public ApfStats() {
50     }
51 
ApfStats(Parcel in)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.programUpdatesAll = in.readInt();
61         this.programUpdatesAllowingMulticast = in.readInt();
62         this.maxProgramSize = in.readInt();
63     }
64 
65     @Override
writeToParcel(Parcel out, int flags)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);
74         out.writeInt(programUpdatesAll);
75         out.writeInt(programUpdatesAllowingMulticast);
76         out.writeInt(maxProgramSize);
77     }
78 
79     @Override
describeContents()80     public int describeContents() {
81         return 0;
82     }
83 
84     @Override
toString()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))
93                 .append(String.format("%d parse errors}, ", parseErrors))
94                 .append(String.format("updates: {all: %d, RAs: %d, allow multicast: %d})",
95                         programUpdatesAll, programUpdates, programUpdatesAllowingMulticast))
96                 .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 }
109