1 package org.openflow.protocol.statistics;
3 import java.nio.ByteBuffer;
6 * Represents an ofp_port_stats structure
7 * @author David Erickson (daviderickson@cs.stanford.edu)
9 public class OFPortStatisticsReply implements OFStatistics {
10 protected short portNumber;
11 protected long receivePackets;
12 protected long transmitPackets;
13 protected long receiveBytes;
14 protected long transmitBytes;
15 protected long receiveDropped;
16 protected long transmitDropped;
17 protected long receiveErrors;
18 protected long transmitErrors;
19 protected long receiveFrameErrors;
20 protected long receiveOverrunErrors;
21 protected long receiveCRCErrors;
22 protected long collisions;
25 * @return the portNumber
27 public short getPortNumber() {
32 * @param portNumber the portNumber to set
34 public void setPortNumber(short portNumber) {
35 this.portNumber = portNumber;
39 * @return the receivePackets
41 public long getreceivePackets() {
42 return receivePackets;
46 * @param receivePackets the receivePackets to set
48 public void setreceivePackets(long receivePackets) {
49 this.receivePackets = receivePackets;
53 * @return the transmitPackets
55 public long getTransmitPackets() {
56 return transmitPackets;
60 * @param transmitPackets the transmitPackets to set
62 public void setTransmitPackets(long transmitPackets) {
63 this.transmitPackets = transmitPackets;
67 * @return the receiveBytes
69 public long getReceiveBytes() {
74 * @param receiveBytes the receiveBytes to set
76 public void setReceiveBytes(long receiveBytes) {
77 this.receiveBytes = receiveBytes;
81 * @return the transmitBytes
83 public long getTransmitBytes() {
88 * @param transmitBytes the transmitBytes to set
90 public void setTransmitBytes(long transmitBytes) {
91 this.transmitBytes = transmitBytes;
95 * @return the receiveDropped
97 public long getReceiveDropped() {
98 return receiveDropped;
102 * @param receiveDropped the receiveDropped to set
104 public void setReceiveDropped(long receiveDropped) {
105 this.receiveDropped = receiveDropped;
109 * @return the transmitDropped
111 public long getTransmitDropped() {
112 return transmitDropped;
116 * @param transmitDropped the transmitDropped to set
118 public void setTransmitDropped(long transmitDropped) {
119 this.transmitDropped = transmitDropped;
123 * @return the receiveErrors
125 public long getreceiveErrors() {
126 return receiveErrors;
130 * @param receiveErrors the receiveErrors to set
132 public void setreceiveErrors(long receiveErrors) {
133 this.receiveErrors = receiveErrors;
137 * @return the transmitErrors
139 public long getTransmitErrors() {
140 return transmitErrors;
144 * @param transmitErrors the transmitErrors to set
146 public void setTransmitErrors(long transmitErrors) {
147 this.transmitErrors = transmitErrors;
151 * @return the receiveFrameErrors
153 public long getReceiveFrameErrors() {
154 return receiveFrameErrors;
158 * @param receiveFrameErrors the receiveFrameErrors to set
160 public void setReceiveFrameErrors(long receiveFrameErrors) {
161 this.receiveFrameErrors = receiveFrameErrors;
165 * @return the receiveOverrunErrors
167 public long getReceiveOverrunErrors() {
168 return receiveOverrunErrors;
172 * @param receiveOverrunErrors the receiveOverrunErrors to set
174 public void setReceiveOverrunErrors(long receiveOverrunErrors) {
175 this.receiveOverrunErrors = receiveOverrunErrors;
179 * @return the receiveCRCErrors
181 public long getReceiveCRCErrors() {
182 return receiveCRCErrors;
186 * @param receiveCRCErrors the receiveCRCErrors to set
188 public void setReceiveCRCErrors(long receiveCRCErrors) {
189 this.receiveCRCErrors = receiveCRCErrors;
193 * @return the collisions
195 public long getCollisions() {
200 * @param collisions the collisions to set
202 public void setCollisions(long collisions) {
203 this.collisions = collisions;
207 public int getLength() {
212 public void readFrom(ByteBuffer data) {
213 this.portNumber = data.getShort();
214 data.getShort(); // pad
215 data.getInt(); // pad
216 this.receivePackets = data.getLong();
217 this.transmitPackets = data.getLong();
218 this.receiveBytes = data.getLong();
219 this.transmitBytes = data.getLong();
220 this.receiveDropped = data.getLong();
221 this.transmitDropped = data.getLong();
222 this.receiveErrors = data.getLong();
223 this.transmitErrors = data.getLong();
224 this.receiveFrameErrors = data.getLong();
225 this.receiveOverrunErrors = data.getLong();
226 this.receiveCRCErrors = data.getLong();
227 this.collisions = data.getLong();
231 public void writeTo(ByteBuffer data) {
232 data.putShort(this.portNumber);
233 data.putShort((short) 0); // pad
234 data.putInt(0); // pad
235 data.putLong(this.receivePackets);
236 data.putLong(this.transmitPackets);
237 data.putLong(this.receiveBytes);
238 data.putLong(this.transmitBytes);
239 data.putLong(this.receiveDropped);
240 data.putLong(this.transmitDropped);
241 data.putLong(this.receiveErrors);
242 data.putLong(this.transmitErrors);
243 data.putLong(this.receiveFrameErrors);
244 data.putLong(this.receiveOverrunErrors);
245 data.putLong(this.receiveCRCErrors);
246 data.putLong(this.collisions);
250 public int hashCode() {
251 final int prime = 431;
253 result = prime * result + (int) (collisions ^ (collisions >>> 32));
254 result = prime * result + portNumber;
255 result = prime * result
256 + (int) (receivePackets ^ (receivePackets >>> 32));
257 result = prime * result + (int) (receiveBytes ^ (receiveBytes >>> 32));
258 result = prime * result
259 + (int) (receiveCRCErrors ^ (receiveCRCErrors >>> 32));
260 result = prime * result
261 + (int) (receiveDropped ^ (receiveDropped >>> 32));
262 result = prime * result
263 + (int) (receiveFrameErrors ^ (receiveFrameErrors >>> 32));
264 result = prime * result
265 + (int) (receiveOverrunErrors ^ (receiveOverrunErrors >>> 32));
266 result = prime * result
267 + (int) (receiveErrors ^ (receiveErrors >>> 32));
268 result = prime * result
269 + (int) (transmitBytes ^ (transmitBytes >>> 32));
270 result = prime * result
271 + (int) (transmitDropped ^ (transmitDropped >>> 32));
272 result = prime * result
273 + (int) (transmitErrors ^ (transmitErrors >>> 32));
274 result = prime * result
275 + (int) (transmitPackets ^ (transmitPackets >>> 32));
280 public boolean equals(Object obj) {
287 if (!(obj instanceof OFPortStatisticsReply)) {
290 OFPortStatisticsReply other = (OFPortStatisticsReply) obj;
291 if (collisions != other.collisions) {
294 if (portNumber != other.portNumber) {
297 if (receivePackets != other.receivePackets) {
300 if (receiveBytes != other.receiveBytes) {
303 if (receiveCRCErrors != other.receiveCRCErrors) {
306 if (receiveDropped != other.receiveDropped) {
309 if (receiveFrameErrors != other.receiveFrameErrors) {
312 if (receiveOverrunErrors != other.receiveOverrunErrors) {
315 if (receiveErrors != other.receiveErrors) {
318 if (transmitBytes != other.transmitBytes) {
321 if (transmitDropped != other.transmitDropped) {
324 if (transmitErrors != other.transmitErrors) {
327 if (transmitPackets != other.transmitPackets) {