blob: 7dec16b69d8d295985363703585fb82ab08f3da1 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
3* University
4*
5* Licensed under the Apache License, Version 2.0 (the "License"); you may
6* not use this file except in compliance with the License. You may obtain
7* a copy of the License at
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14* License for the specific language governing permissions and limitations
15* under the License.
16**/
17
18package org.openflow.protocol.statistics;
19
20
21import org.codehaus.jackson.annotate.JsonIgnore;
22import org.jboss.netty.buffer.ChannelBuffer;
23
24/**
25 * Represents an ofp_aggregate_stats_reply structure
26 * @author David Erickson (daviderickson@cs.stanford.edu)
27 */
28public class OFAggregateStatisticsReply implements OFStatistics {
29 protected long packetCount;
30 protected long byteCount;
31 protected int flowCount;
32
33 /**
34 * @return the packetCount
35 */
36 public long getPacketCount() {
37 return packetCount;
38 }
39
40 /**
41 * @param packetCount the packetCount to set
42 */
43 public void setPacketCount(long packetCount) {
44 this.packetCount = packetCount;
45 }
46
47 /**
48 * @return the byteCount
49 */
50 public long getByteCount() {
51 return byteCount;
52 }
53
54 /**
55 * @param byteCount the byteCount to set
56 */
57 public void setByteCount(long byteCount) {
58 this.byteCount = byteCount;
59 }
60
61 /**
62 * @return the flowCount
63 */
64 public int getFlowCount() {
65 return flowCount;
66 }
67
68 /**
69 * @param flowCount the flowCount to set
70 */
71 public void setFlowCount(int flowCount) {
72 this.flowCount = flowCount;
73 }
74
75 @Override
76 @JsonIgnore
77 public int getLength() {
78 return 24;
79 }
80
81 @Override
82 public void readFrom(ChannelBuffer data) {
83 this.packetCount = data.readLong();
84 this.byteCount = data.readLong();
85 this.flowCount = data.readInt();
86 data.readInt(); // pad
87 }
88
89 @Override
90 public void writeTo(ChannelBuffer data) {
91 data.writeLong(this.packetCount);
92 data.writeLong(this.byteCount);
93 data.writeInt(this.flowCount);
94 data.writeInt(0); // pad
95 }
96
97 @Override
98 public int hashCode() {
99 final int prime = 397;
100 int result = 1;
101 result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
102 result = prime * result + flowCount;
103 result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
104 return result;
105 }
106
107 @Override
108 public boolean equals(Object obj) {
109 if (this == obj) {
110 return true;
111 }
112 if (obj == null) {
113 return false;
114 }
115 if (!(obj instanceof OFAggregateStatisticsReply)) {
116 return false;
117 }
118 OFAggregateStatisticsReply other = (OFAggregateStatisticsReply) obj;
119 if (byteCount != other.byteCount) {
120 return false;
121 }
122 if (flowCount != other.flowCount) {
123 return false;
124 }
125 if (packetCount != other.packetCount) {
126 return false;
127 }
128 return true;
129 }
130}