2 * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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
18 package org.openflow.protocol.statistics;
22 import org.jboss.netty.buffer.ChannelBuffer;
25 * Represents an ofp_port_stats structure
26 * @author David Erickson (daviderickson@cs.stanford.edu)
28 public class OFPortStatisticsReply implements OFStatistics {
29 protected short portNumber;
30 protected long receivePackets;
31 protected long transmitPackets;
32 protected long receiveBytes;
33 protected long transmitBytes;
34 protected long receiveDropped;
35 protected long transmitDropped;
36 protected long receiveErrors;
37 protected long transmitErrors;
38 protected long receiveFrameErrors;
39 protected long receiveOverrunErrors;
40 protected long receiveCRCErrors;
41 protected long collisions;
44 * @return the portNumber
46 public short getPortNumber() {
51 * @param portNumber the portNumber to set
53 public void setPortNumber(short portNumber) {
54 this.portNumber = portNumber;
58 * @return the receivePackets
60 public long getreceivePackets() {
61 return receivePackets;
65 * @param receivePackets the receivePackets to set
67 public void setreceivePackets(long receivePackets) {
68 this.receivePackets = receivePackets;
72 * @return the transmitPackets
74 public long getTransmitPackets() {
75 return transmitPackets;
79 * @param transmitPackets the transmitPackets to set
81 public void setTransmitPackets(long transmitPackets) {
82 this.transmitPackets = transmitPackets;
86 * @return the receiveBytes
88 public long getReceiveBytes() {
93 * @param receiveBytes the receiveBytes to set
95 public void setReceiveBytes(long receiveBytes) {
96 this.receiveBytes = receiveBytes;
100 * @return the transmitBytes
102 public long getTransmitBytes() {
103 return transmitBytes;
107 * @param transmitBytes the transmitBytes to set
109 public void setTransmitBytes(long transmitBytes) {
110 this.transmitBytes = transmitBytes;
114 * @return the receiveDropped
116 public long getReceiveDropped() {
117 return receiveDropped;
121 * @param receiveDropped the receiveDropped to set
123 public void setReceiveDropped(long receiveDropped) {
124 this.receiveDropped = receiveDropped;
128 * @return the transmitDropped
130 public long getTransmitDropped() {
131 return transmitDropped;
135 * @param transmitDropped the transmitDropped to set
137 public void setTransmitDropped(long transmitDropped) {
138 this.transmitDropped = transmitDropped;
142 * @return the receiveErrors
144 public long getreceiveErrors() {
145 return receiveErrors;
149 * @param receiveErrors the receiveErrors to set
151 public void setreceiveErrors(long receiveErrors) {
152 this.receiveErrors = receiveErrors;
156 * @return the transmitErrors
158 public long getTransmitErrors() {
159 return transmitErrors;
163 * @param transmitErrors the transmitErrors to set
165 public void setTransmitErrors(long transmitErrors) {
166 this.transmitErrors = transmitErrors;
170 * @return the receiveFrameErrors
172 public long getReceiveFrameErrors() {
173 return receiveFrameErrors;
177 * @param receiveFrameErrors the receiveFrameErrors to set
179 public void setReceiveFrameErrors(long receiveFrameErrors) {
180 this.receiveFrameErrors = receiveFrameErrors;
184 * @return the receiveOverrunErrors
186 public long getReceiveOverrunErrors() {
187 return receiveOverrunErrors;
191 * @param receiveOverrunErrors the receiveOverrunErrors to set
193 public void setReceiveOverrunErrors(long receiveOverrunErrors) {
194 this.receiveOverrunErrors = receiveOverrunErrors;
198 * @return the receiveCRCErrors
200 public long getReceiveCRCErrors() {
201 return receiveCRCErrors;
205 * @param receiveCRCErrors the receiveCRCErrors to set
207 public void setReceiveCRCErrors(long receiveCRCErrors) {
208 this.receiveCRCErrors = receiveCRCErrors;
212 * @return the collisions
214 public long getCollisions() {
219 * @param collisions the collisions to set
221 public void setCollisions(long collisions) {
222 this.collisions = collisions;
226 public int getLength() {
231 public void readFrom(ChannelBuffer data) {
232 this.portNumber = data.readShort();
233 data.readShort(); // pad
234 data.readInt(); // pad
235 this.receivePackets = data.readLong();
236 this.transmitPackets = data.readLong();
237 this.receiveBytes = data.readLong();
238 this.transmitBytes = data.readLong();
239 this.receiveDropped = data.readLong();
240 this.transmitDropped = data.readLong();
241 this.receiveErrors = data.readLong();
242 this.transmitErrors = data.readLong();
243 this.receiveFrameErrors = data.readLong();
244 this.receiveOverrunErrors = data.readLong();
245 this.receiveCRCErrors = data.readLong();
246 this.collisions = data.readLong();
250 public void writeTo(ChannelBuffer data) {
251 data.writeShort(this.portNumber);
252 data.writeShort((short) 0); // pad
253 data.writeInt(0); // pad
254 data.writeLong(this.receivePackets);
255 data.writeLong(this.transmitPackets);
256 data.writeLong(this.receiveBytes);
257 data.writeLong(this.transmitBytes);
258 data.writeLong(this.receiveDropped);
259 data.writeLong(this.transmitDropped);
260 data.writeLong(this.receiveErrors);
261 data.writeLong(this.transmitErrors);
262 data.writeLong(this.receiveFrameErrors);
263 data.writeLong(this.receiveOverrunErrors);
264 data.writeLong(this.receiveCRCErrors);
265 data.writeLong(this.collisions);
269 public int hashCode() {
270 final int prime = 431;
272 result = prime * result + (int) (collisions ^ (collisions >>> 32));
273 result = prime * result + portNumber;
274 result = prime * result
275 + (int) (receivePackets ^ (receivePackets >>> 32));
276 result = prime * result + (int) (receiveBytes ^ (receiveBytes >>> 32));
277 result = prime * result
278 + (int) (receiveCRCErrors ^ (receiveCRCErrors >>> 32));
279 result = prime * result
280 + (int) (receiveDropped ^ (receiveDropped >>> 32));
281 result = prime * result
282 + (int) (receiveFrameErrors ^ (receiveFrameErrors >>> 32));
283 result = prime * result
284 + (int) (receiveOverrunErrors ^ (receiveOverrunErrors >>> 32));
285 result = prime * result
286 + (int) (receiveErrors ^ (receiveErrors >>> 32));
287 result = prime * result
288 + (int) (transmitBytes ^ (transmitBytes >>> 32));
289 result = prime * result
290 + (int) (transmitDropped ^ (transmitDropped >>> 32));
291 result = prime * result
292 + (int) (transmitErrors ^ (transmitErrors >>> 32));
293 result = prime * result
294 + (int) (transmitPackets ^ (transmitPackets >>> 32));
299 public boolean equals(Object obj) {
306 if (!(obj instanceof OFPortStatisticsReply)) {
309 OFPortStatisticsReply other = (OFPortStatisticsReply) obj;
310 if (collisions != other.collisions) {
313 if (portNumber != other.portNumber) {
316 if (receivePackets != other.receivePackets) {
319 if (receiveBytes != other.receiveBytes) {
322 if (receiveCRCErrors != other.receiveCRCErrors) {
325 if (receiveDropped != other.receiveDropped) {
328 if (receiveFrameErrors != other.receiveFrameErrors) {
331 if (receiveOverrunErrors != other.receiveOverrunErrors) {
334 if (receiveErrors != other.receiveErrors) {
337 if (transmitBytes != other.transmitBytes) {
340 if (transmitDropped != other.transmitDropped) {
343 if (transmitErrors != other.transmitErrors) {
346 if (transmitPackets != other.transmitPackets) {