Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 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 | |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | /** |
Erik Kline | 8d1fe54 | 2018-03-12 23:18:58 +0900 | [diff] [blame] | 23 | * An event logged for an interface with APF capabilities when its IpClient state machine exits. |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 24 | * {@hide} |
| 25 | */ |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 26 | public final class ApfStats implements Parcelable { |
| 27 | |
Hugo Benichi | 22d9b2d | 2017-02-22 13:02:27 +0900 | [diff] [blame] | 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; |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 48 | |
Hugo Benichi | 22d9b2d | 2017-02-22 13:02:27 +0900 | [diff] [blame] | 49 | public ApfStats() { |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 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(); |
Hugo Benichi | 22d9b2d | 2017-02-22 13:02:27 +0900 | [diff] [blame] | 60 | this.programUpdatesAll = in.readInt(); |
| 61 | this.programUpdatesAllowingMulticast = in.readInt(); |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 62 | 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 Benichi | 22d9b2d | 2017-02-22 13:02:27 +0900 | [diff] [blame] | 74 | out.writeInt(programUpdatesAll); |
| 75 | out.writeInt(programUpdatesAllowingMulticast); |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 76 | 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 Benichi | 22d9b2d | 2017-02-22 13:02:27 +0900 | [diff] [blame] | 93 | .append(String.format("%d parse errors}, ", parseErrors)) |
| 94 | .append(String.format("updates: {all: %d, RAs: %d, allow multicast: %d})", |
| 95 | programUpdatesAll, programUpdates, programUpdatesAllowingMulticast)) |
Hugo Benichi | 647c86d | 2016-06-07 15:35:16 +0900 | [diff] [blame] | 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 | } |