blob: 03cbb9cef0c87b3056a57fef8c309e2ad2d1ed23 [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_queue_stats structure
26 * @author David Erickson (daviderickson@cs.stanford.edu)
27 */
28public class OFQueueStatisticsReply implements OFStatistics {
29 protected short portNumber;
30 protected int queueId;
31 protected long transmitBytes;
32 protected long transmitPackets;
33 protected long transmitErrors;
34
35 /**
36 * @return the portNumber
37 */
38 public short getPortNumber() {
39 return portNumber;
40 }
41
42 /**
43 * @param portNumber the portNumber to set
44 */
45 public void setPortNumber(short portNumber) {
46 this.portNumber = portNumber;
47 }
48
49 /**
50 * @return the queueId
51 */
52 public int getQueueId() {
53 return queueId;
54 }
55
56 /**
57 * @param queueId the queueId to set
58 */
59 public void setQueueId(int queueId) {
60 this.queueId = queueId;
61 }
62
63 /**
64 * @return the transmitBytes
65 */
66 public long getTransmitBytes() {
67 return transmitBytes;
68 }
69
70 /**
71 * @param transmitBytes the transmitBytes to set
72 */
73 public void setTransmitBytes(long transmitBytes) {
74 this.transmitBytes = transmitBytes;
75 }
76
77 /**
78 * @return the transmitPackets
79 */
80 public long getTransmitPackets() {
81 return transmitPackets;
82 }
83
84 /**
85 * @param transmitPackets the transmitPackets to set
86 */
87 public void setTransmitPackets(long transmitPackets) {
88 this.transmitPackets = transmitPackets;
89 }
90
91 /**
92 * @return the transmitErrors
93 */
94 public long getTransmitErrors() {
95 return transmitErrors;
96 }
97
98 /**
99 * @param transmitErrors the transmitErrors to set
100 */
101 public void setTransmitErrors(long transmitErrors) {
102 this.transmitErrors = transmitErrors;
103 }
104
105 @Override
106 @JsonIgnore
107 public int getLength() {
108 return 32;
109 }
110
111 @Override
112 public void readFrom(ChannelBuffer data) {
113 this.portNumber = data.readShort();
114 data.readShort(); // pad
115 this.queueId = data.readInt();
116 this.transmitBytes = data.readLong();
117 this.transmitPackets = data.readLong();
118 this.transmitErrors = data.readLong();
119 }
120
121 @Override
122 public void writeTo(ChannelBuffer data) {
123 data.writeShort(this.portNumber);
124 data.writeShort((short) 0); // pad
125 data.writeInt(this.queueId);
126 data.writeLong(this.transmitBytes);
127 data.writeLong(this.transmitPackets);
128 data.writeLong(this.transmitErrors);
129 }
130
131 @Override
132 public int hashCode() {
133 final int prime = 439;
134 int result = 1;
135 result = prime * result + portNumber;
136 result = prime * result + queueId;
137 result = prime * result
138 + (int) (transmitBytes ^ (transmitBytes >>> 32));
139 result = prime * result
140 + (int) (transmitErrors ^ (transmitErrors >>> 32));
141 result = prime * result
142 + (int) (transmitPackets ^ (transmitPackets >>> 32));
143 return result;
144 }
145
146 @Override
147 public boolean equals(Object obj) {
148 if (this == obj) {
149 return true;
150 }
151 if (obj == null) {
152 return false;
153 }
154 if (!(obj instanceof OFQueueStatisticsReply)) {
155 return false;
156 }
157 OFQueueStatisticsReply other = (OFQueueStatisticsReply) obj;
158 if (portNumber != other.portNumber) {
159 return false;
160 }
161 if (queueId != other.queueId) {
162 return false;
163 }
164 if (transmitBytes != other.transmitBytes) {
165 return false;
166 }
167 if (transmitErrors != other.transmitErrors) {
168 return false;
169 }
170 if (transmitPackets != other.transmitPackets) {
171 return false;
172 }
173 return true;
174 }
175}