02b97b3328b250f012f60253e34ead1b3d7fb628
[openflowjava.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / statistics / OFPortStatisticsReply.java
1 /**
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
18 package org.openflow.protocol.statistics;
19
20
21
22 import org.jboss.netty.buffer.ChannelBuffer;
23
24 /**
25  * Represents an ofp_port_stats structure
26  * @author David Erickson (daviderickson@cs.stanford.edu)
27  */
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;
42
43     /**
44      * @return the portNumber
45      */
46     public short getPortNumber() {
47         return portNumber;
48     }
49
50     /**
51      * @param portNumber the portNumber to set
52      */
53     public void setPortNumber(short portNumber) {
54         this.portNumber = portNumber;
55     }
56
57     /**
58      * @return the receivePackets
59      */
60     public long getreceivePackets() {
61         return receivePackets;
62     }
63
64     /**
65      * @param receivePackets the receivePackets to set
66      */
67     public void setreceivePackets(long receivePackets) {
68         this.receivePackets = receivePackets;
69     }
70
71     /**
72      * @return the transmitPackets
73      */
74     public long getTransmitPackets() {
75         return transmitPackets;
76     }
77
78     /**
79      * @param transmitPackets the transmitPackets to set
80      */
81     public void setTransmitPackets(long transmitPackets) {
82         this.transmitPackets = transmitPackets;
83     }
84
85     /**
86      * @return the receiveBytes
87      */
88     public long getReceiveBytes() {
89         return receiveBytes;
90     }
91
92     /**
93      * @param receiveBytes the receiveBytes to set
94      */
95     public void setReceiveBytes(long receiveBytes) {
96         this.receiveBytes = receiveBytes;
97     }
98
99     /**
100      * @return the transmitBytes
101      */
102     public long getTransmitBytes() {
103         return transmitBytes;
104     }
105
106     /**
107      * @param transmitBytes the transmitBytes to set
108      */
109     public void setTransmitBytes(long transmitBytes) {
110         this.transmitBytes = transmitBytes;
111     }
112
113     /**
114      * @return the receiveDropped
115      */
116     public long getReceiveDropped() {
117         return receiveDropped;
118     }
119
120     /**
121      * @param receiveDropped the receiveDropped to set
122      */
123     public void setReceiveDropped(long receiveDropped) {
124         this.receiveDropped = receiveDropped;
125     }
126
127     /**
128      * @return the transmitDropped
129      */
130     public long getTransmitDropped() {
131         return transmitDropped;
132     }
133
134     /**
135      * @param transmitDropped the transmitDropped to set
136      */
137     public void setTransmitDropped(long transmitDropped) {
138         this.transmitDropped = transmitDropped;
139     }
140
141     /**
142      * @return the receiveErrors
143      */
144     public long getreceiveErrors() {
145         return receiveErrors;
146     }
147
148     /**
149      * @param receiveErrors the receiveErrors to set
150      */
151     public void setreceiveErrors(long receiveErrors) {
152         this.receiveErrors = receiveErrors;
153     }
154
155     /**
156      * @return the transmitErrors
157      */
158     public long getTransmitErrors() {
159         return transmitErrors;
160     }
161
162     /**
163      * @param transmitErrors the transmitErrors to set
164      */
165     public void setTransmitErrors(long transmitErrors) {
166         this.transmitErrors = transmitErrors;
167     }
168
169     /**
170      * @return the receiveFrameErrors
171      */
172     public long getReceiveFrameErrors() {
173         return receiveFrameErrors;
174     }
175
176     /**
177      * @param receiveFrameErrors the receiveFrameErrors to set
178      */
179     public void setReceiveFrameErrors(long receiveFrameErrors) {
180         this.receiveFrameErrors = receiveFrameErrors;
181     }
182
183     /**
184      * @return the receiveOverrunErrors
185      */
186     public long getReceiveOverrunErrors() {
187         return receiveOverrunErrors;
188     }
189
190     /**
191      * @param receiveOverrunErrors the receiveOverrunErrors to set
192      */
193     public void setReceiveOverrunErrors(long receiveOverrunErrors) {
194         this.receiveOverrunErrors = receiveOverrunErrors;
195     }
196
197     /**
198      * @return the receiveCRCErrors
199      */
200     public long getReceiveCRCErrors() {
201         return receiveCRCErrors;
202     }
203
204     /**
205      * @param receiveCRCErrors the receiveCRCErrors to set
206      */
207     public void setReceiveCRCErrors(long receiveCRCErrors) {
208         this.receiveCRCErrors = receiveCRCErrors;
209     }
210
211     /**
212      * @return the collisions
213      */
214     public long getCollisions() {
215         return collisions;
216     }
217
218     /**
219      * @param collisions the collisions to set
220      */
221     public void setCollisions(long collisions) {
222         this.collisions = collisions;
223     }
224
225     @Override
226     public int getLength() {
227         return 104;
228     }
229
230     @Override
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();
247     }
248
249     @Override
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);
266     }
267
268     @Override
269     public int hashCode() {
270         final int prime = 431;
271         int result = 1;
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));
295         return result;
296     }
297
298     @Override
299     public boolean equals(Object obj) {
300         if (this == obj) {
301             return true;
302         }
303         if (obj == null) {
304             return false;
305         }
306         if (!(obj instanceof OFPortStatisticsReply)) {
307             return false;
308         }
309         OFPortStatisticsReply other = (OFPortStatisticsReply) obj;
310         if (collisions != other.collisions) {
311             return false;
312         }
313         if (portNumber != other.portNumber) {
314             return false;
315         }
316         if (receivePackets != other.receivePackets) {
317             return false;
318         }
319         if (receiveBytes != other.receiveBytes) {
320             return false;
321         }
322         if (receiveCRCErrors != other.receiveCRCErrors) {
323             return false;
324         }
325         if (receiveDropped != other.receiveDropped) {
326             return false;
327         }
328         if (receiveFrameErrors != other.receiveFrameErrors) {
329             return false;
330         }
331         if (receiveOverrunErrors != other.receiveOverrunErrors) {
332             return false;
333         }
334         if (receiveErrors != other.receiveErrors) {
335             return false;
336         }
337         if (transmitBytes != other.transmitBytes) {
338             return false;
339         }
340         if (transmitDropped != other.transmitDropped) {
341             return false;
342         }
343         if (transmitErrors != other.transmitErrors) {
344             return false;
345         }
346         if (transmitPackets != other.transmitPackets) {
347             return false;
348         }
349         return true;
350     }
351 }