Initial opendaylight infrastructure commit!!
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / statistics / OFPortStatisticsReply.java
1 package org.openflow.protocol.statistics;
2
3 import java.nio.ByteBuffer;
4
5 /**
6  * Represents an ofp_port_stats structure
7  * @author David Erickson (daviderickson@cs.stanford.edu)
8  */
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;
23
24     /**
25      * @return the portNumber
26      */
27     public short getPortNumber() {
28         return portNumber;
29     }
30
31     /**
32      * @param portNumber the portNumber to set
33      */
34     public void setPortNumber(short portNumber) {
35         this.portNumber = portNumber;
36     }
37
38     /**
39      * @return the receivePackets
40      */
41     public long getreceivePackets() {
42         return receivePackets;
43     }
44
45     /**
46      * @param receivePackets the receivePackets to set
47      */
48     public void setreceivePackets(long receivePackets) {
49         this.receivePackets = receivePackets;
50     }
51
52     /**
53      * @return the transmitPackets
54      */
55     public long getTransmitPackets() {
56         return transmitPackets;
57     }
58
59     /**
60      * @param transmitPackets the transmitPackets to set
61      */
62     public void setTransmitPackets(long transmitPackets) {
63         this.transmitPackets = transmitPackets;
64     }
65
66     /**
67      * @return the receiveBytes
68      */
69     public long getReceiveBytes() {
70         return receiveBytes;
71     }
72
73     /**
74      * @param receiveBytes the receiveBytes to set
75      */
76     public void setReceiveBytes(long receiveBytes) {
77         this.receiveBytes = receiveBytes;
78     }
79
80     /**
81      * @return the transmitBytes
82      */
83     public long getTransmitBytes() {
84         return transmitBytes;
85     }
86
87     /**
88      * @param transmitBytes the transmitBytes to set
89      */
90     public void setTransmitBytes(long transmitBytes) {
91         this.transmitBytes = transmitBytes;
92     }
93
94     /**
95      * @return the receiveDropped
96      */
97     public long getReceiveDropped() {
98         return receiveDropped;
99     }
100
101     /**
102      * @param receiveDropped the receiveDropped to set
103      */
104     public void setReceiveDropped(long receiveDropped) {
105         this.receiveDropped = receiveDropped;
106     }
107
108     /**
109      * @return the transmitDropped
110      */
111     public long getTransmitDropped() {
112         return transmitDropped;
113     }
114
115     /**
116      * @param transmitDropped the transmitDropped to set
117      */
118     public void setTransmitDropped(long transmitDropped) {
119         this.transmitDropped = transmitDropped;
120     }
121
122     /**
123      * @return the receiveErrors
124      */
125     public long getreceiveErrors() {
126         return receiveErrors;
127     }
128
129     /**
130      * @param receiveErrors the receiveErrors to set
131      */
132     public void setreceiveErrors(long receiveErrors) {
133         this.receiveErrors = receiveErrors;
134     }
135
136     /**
137      * @return the transmitErrors
138      */
139     public long getTransmitErrors() {
140         return transmitErrors;
141     }
142
143     /**
144      * @param transmitErrors the transmitErrors to set
145      */
146     public void setTransmitErrors(long transmitErrors) {
147         this.transmitErrors = transmitErrors;
148     }
149
150     /**
151      * @return the receiveFrameErrors
152      */
153     public long getReceiveFrameErrors() {
154         return receiveFrameErrors;
155     }
156
157     /**
158      * @param receiveFrameErrors the receiveFrameErrors to set
159      */
160     public void setReceiveFrameErrors(long receiveFrameErrors) {
161         this.receiveFrameErrors = receiveFrameErrors;
162     }
163
164     /**
165      * @return the receiveOverrunErrors
166      */
167     public long getReceiveOverrunErrors() {
168         return receiveOverrunErrors;
169     }
170
171     /**
172      * @param receiveOverrunErrors the receiveOverrunErrors to set
173      */
174     public void setReceiveOverrunErrors(long receiveOverrunErrors) {
175         this.receiveOverrunErrors = receiveOverrunErrors;
176     }
177
178     /**
179      * @return the receiveCRCErrors
180      */
181     public long getReceiveCRCErrors() {
182         return receiveCRCErrors;
183     }
184
185     /**
186      * @param receiveCRCErrors the receiveCRCErrors to set
187      */
188     public void setReceiveCRCErrors(long receiveCRCErrors) {
189         this.receiveCRCErrors = receiveCRCErrors;
190     }
191
192     /**
193      * @return the collisions
194      */
195     public long getCollisions() {
196         return collisions;
197     }
198
199     /**
200      * @param collisions the collisions to set
201      */
202     public void setCollisions(long collisions) {
203         this.collisions = collisions;
204     }
205
206     @Override
207     public int getLength() {
208         return 104;
209     }
210
211     @Override
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();
228     }
229
230     @Override
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);
247     }
248
249     @Override
250     public int hashCode() {
251         final int prime = 431;
252         int result = 1;
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));
276         return result;
277     }
278
279     @Override
280     public boolean equals(Object obj) {
281         if (this == obj) {
282             return true;
283         }
284         if (obj == null) {
285             return false;
286         }
287         if (!(obj instanceof OFPortStatisticsReply)) {
288             return false;
289         }
290         OFPortStatisticsReply other = (OFPortStatisticsReply) obj;
291         if (collisions != other.collisions) {
292             return false;
293         }
294         if (portNumber != other.portNumber) {
295             return false;
296         }
297         if (receivePackets != other.receivePackets) {
298             return false;
299         }
300         if (receiveBytes != other.receiveBytes) {
301             return false;
302         }
303         if (receiveCRCErrors != other.receiveCRCErrors) {
304             return false;
305         }
306         if (receiveDropped != other.receiveDropped) {
307             return false;
308         }
309         if (receiveFrameErrors != other.receiveFrameErrors) {
310             return false;
311         }
312         if (receiveOverrunErrors != other.receiveOverrunErrors) {
313             return false;
314         }
315         if (receiveErrors != other.receiveErrors) {
316             return false;
317         }
318         if (transmitBytes != other.transmitBytes) {
319             return false;
320         }
321         if (transmitDropped != other.transmitDropped) {
322             return false;
323         }
324         if (transmitErrors != other.transmitErrors) {
325             return false;
326         }
327         if (transmitPackets != other.transmitPackets) {
328             return false;
329         }
330         return true;
331     }
332 }