blob: 93549363b03fa27e83af91a569ed4562076cb36a [file] [log] [blame]
alshabib86ac11c2014-08-14 16:14:41 -07001// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2// Copyright (c) 2011, 2012 Open Networking Foundation
3// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4// This library was generated by the LoxiGen Compiler.
5// See the file LICENSE.txt which should have been included in the source distribution
6
7// Automatically generated by LOXI from template of_class.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver10;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28import java.util.Set;
29import org.jboss.netty.buffer.ChannelBuffer;
30import com.google.common.hash.PrimitiveSink;
31import com.google.common.hash.Funnel;
32
33class OFQueueStatsEntryVer10 implements OFQueueStatsEntry {
34 private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsEntryVer10.class);
35 // version: 1.0
36 final static byte WIRE_VERSION = 1;
37 final static int LENGTH = 32;
38
39 private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
40 private final static long DEFAULT_QUEUE_ID = 0x0L;
41 private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
42 private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
43 private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
44
45 // OF message fields
46 private final OFPort portNo;
47 private final long queueId;
48 private final U64 txBytes;
49 private final U64 txPackets;
50 private final U64 txErrors;
51//
52 // Immutable default instance
53 final static OFQueueStatsEntryVer10 DEFAULT = new OFQueueStatsEntryVer10(
54 DEFAULT_PORT_NO, DEFAULT_QUEUE_ID, DEFAULT_TX_BYTES, DEFAULT_TX_PACKETS, DEFAULT_TX_ERRORS
55 );
56
57 // package private constructor - used by readers, builders, and factory
58 OFQueueStatsEntryVer10(OFPort portNo, long queueId, U64 txBytes, U64 txPackets, U64 txErrors) {
59 this.portNo = portNo;
60 this.queueId = queueId;
61 this.txBytes = txBytes;
62 this.txPackets = txPackets;
63 this.txErrors = txErrors;
64 }
65
66 // Accessors for OF message fields
67 @Override
68 public OFPort getPortNo() {
69 return portNo;
70 }
71
72 @Override
73 public long getQueueId() {
74 return queueId;
75 }
76
77 @Override
78 public U64 getTxBytes() {
79 return txBytes;
80 }
81
82 @Override
83 public U64 getTxPackets() {
84 return txPackets;
85 }
86
87 @Override
88 public U64 getTxErrors() {
89 return txErrors;
90 }
91
92 @Override
93 public long getDurationSec()throws UnsupportedOperationException {
94 throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
95 }
96
97 @Override
98 public long getDurationNsec()throws UnsupportedOperationException {
99 throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
100 }
101
102 @Override
103 public OFVersion getVersion() {
104 return OFVersion.OF_10;
105 }
106
107
108
109 public OFQueueStatsEntry.Builder createBuilder() {
110 return new BuilderWithParent(this);
111 }
112
113 static class BuilderWithParent implements OFQueueStatsEntry.Builder {
114 final OFQueueStatsEntryVer10 parentMessage;
115
116 // OF message fields
117 private boolean portNoSet;
118 private OFPort portNo;
119 private boolean queueIdSet;
120 private long queueId;
121 private boolean txBytesSet;
122 private U64 txBytes;
123 private boolean txPacketsSet;
124 private U64 txPackets;
125 private boolean txErrorsSet;
126 private U64 txErrors;
127
128 BuilderWithParent(OFQueueStatsEntryVer10 parentMessage) {
129 this.parentMessage = parentMessage;
130 }
131
132 @Override
133 public OFPort getPortNo() {
134 return portNo;
135 }
136
137 @Override
138 public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
139 this.portNo = portNo;
140 this.portNoSet = true;
141 return this;
142 }
143 @Override
144 public long getQueueId() {
145 return queueId;
146 }
147
148 @Override
149 public OFQueueStatsEntry.Builder setQueueId(long queueId) {
150 this.queueId = queueId;
151 this.queueIdSet = true;
152 return this;
153 }
154 @Override
155 public U64 getTxBytes() {
156 return txBytes;
157 }
158
159 @Override
160 public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
161 this.txBytes = txBytes;
162 this.txBytesSet = true;
163 return this;
164 }
165 @Override
166 public U64 getTxPackets() {
167 return txPackets;
168 }
169
170 @Override
171 public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
172 this.txPackets = txPackets;
173 this.txPacketsSet = true;
174 return this;
175 }
176 @Override
177 public U64 getTxErrors() {
178 return txErrors;
179 }
180
181 @Override
182 public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
183 this.txErrors = txErrors;
184 this.txErrorsSet = true;
185 return this;
186 }
187 @Override
188 public long getDurationSec()throws UnsupportedOperationException {
189 throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
190 }
191
192 @Override
193 public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
194 throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
195 }
196 @Override
197 public long getDurationNsec()throws UnsupportedOperationException {
198 throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
199 }
200
201 @Override
202 public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
203 throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
204 }
205 @Override
206 public OFVersion getVersion() {
207 return OFVersion.OF_10;
208 }
209
210
211
212 @Override
213 public OFQueueStatsEntry build() {
214 OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
215 if(portNo == null)
216 throw new NullPointerException("Property portNo must not be null");
217 long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
218 U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
219 if(txBytes == null)
220 throw new NullPointerException("Property txBytes must not be null");
221 U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
222 if(txPackets == null)
223 throw new NullPointerException("Property txPackets must not be null");
224 U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
225 if(txErrors == null)
226 throw new NullPointerException("Property txErrors must not be null");
227
228 //
229 return new OFQueueStatsEntryVer10(
230 portNo,
231 queueId,
232 txBytes,
233 txPackets,
234 txErrors
235 );
236 }
237
238 }
239
240 static class Builder implements OFQueueStatsEntry.Builder {
241 // OF message fields
242 private boolean portNoSet;
243 private OFPort portNo;
244 private boolean queueIdSet;
245 private long queueId;
246 private boolean txBytesSet;
247 private U64 txBytes;
248 private boolean txPacketsSet;
249 private U64 txPackets;
250 private boolean txErrorsSet;
251 private U64 txErrors;
252
253 @Override
254 public OFPort getPortNo() {
255 return portNo;
256 }
257
258 @Override
259 public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
260 this.portNo = portNo;
261 this.portNoSet = true;
262 return this;
263 }
264 @Override
265 public long getQueueId() {
266 return queueId;
267 }
268
269 @Override
270 public OFQueueStatsEntry.Builder setQueueId(long queueId) {
271 this.queueId = queueId;
272 this.queueIdSet = true;
273 return this;
274 }
275 @Override
276 public U64 getTxBytes() {
277 return txBytes;
278 }
279
280 @Override
281 public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
282 this.txBytes = txBytes;
283 this.txBytesSet = true;
284 return this;
285 }
286 @Override
287 public U64 getTxPackets() {
288 return txPackets;
289 }
290
291 @Override
292 public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
293 this.txPackets = txPackets;
294 this.txPacketsSet = true;
295 return this;
296 }
297 @Override
298 public U64 getTxErrors() {
299 return txErrors;
300 }
301
302 @Override
303 public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
304 this.txErrors = txErrors;
305 this.txErrorsSet = true;
306 return this;
307 }
308 @Override
309 public long getDurationSec()throws UnsupportedOperationException {
310 throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
311 }
312
313 @Override
314 public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
315 throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
316 }
317 @Override
318 public long getDurationNsec()throws UnsupportedOperationException {
319 throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
320 }
321
322 @Override
323 public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
324 throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
325 }
326 @Override
327 public OFVersion getVersion() {
328 return OFVersion.OF_10;
329 }
330
331//
332 @Override
333 public OFQueueStatsEntry build() {
334 OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
335 if(portNo == null)
336 throw new NullPointerException("Property portNo must not be null");
337 long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
338 U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
339 if(txBytes == null)
340 throw new NullPointerException("Property txBytes must not be null");
341 U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
342 if(txPackets == null)
343 throw new NullPointerException("Property txPackets must not be null");
344 U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
345 if(txErrors == null)
346 throw new NullPointerException("Property txErrors must not be null");
347
348
349 return new OFQueueStatsEntryVer10(
350 portNo,
351 queueId,
352 txBytes,
353 txPackets,
354 txErrors
355 );
356 }
357
358 }
359
360
361 final static Reader READER = new Reader();
362 static class Reader implements OFMessageReader<OFQueueStatsEntry> {
363 @Override
364 public OFQueueStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
365 OFPort portNo = OFPort.read2Bytes(bb);
366 // pad: 2 bytes
367 bb.skipBytes(2);
368 long queueId = U32.f(bb.readInt());
369 U64 txBytes = U64.ofRaw(bb.readLong());
370 U64 txPackets = U64.ofRaw(bb.readLong());
371 U64 txErrors = U64.ofRaw(bb.readLong());
372
373 OFQueueStatsEntryVer10 queueStatsEntryVer10 = new OFQueueStatsEntryVer10(
374 portNo,
375 queueId,
376 txBytes,
377 txPackets,
378 txErrors
379 );
380 if(logger.isTraceEnabled())
381 logger.trace("readFrom - read={}", queueStatsEntryVer10);
382 return queueStatsEntryVer10;
383 }
384 }
385
386 public void putTo(PrimitiveSink sink) {
387 FUNNEL.funnel(this, sink);
388 }
389
390 final static OFQueueStatsEntryVer10Funnel FUNNEL = new OFQueueStatsEntryVer10Funnel();
391 static class OFQueueStatsEntryVer10Funnel implements Funnel<OFQueueStatsEntryVer10> {
392 private static final long serialVersionUID = 1L;
393 @Override
394 public void funnel(OFQueueStatsEntryVer10 message, PrimitiveSink sink) {
395 message.portNo.putTo(sink);
396 // skip pad (2 bytes)
397 sink.putLong(message.queueId);
398 message.txBytes.putTo(sink);
399 message.txPackets.putTo(sink);
400 message.txErrors.putTo(sink);
401 }
402 }
403
404
405 public void writeTo(ChannelBuffer bb) {
406 WRITER.write(bb, this);
407 }
408
409 final static Writer WRITER = new Writer();
410 static class Writer implements OFMessageWriter<OFQueueStatsEntryVer10> {
411 @Override
412 public void write(ChannelBuffer bb, OFQueueStatsEntryVer10 message) {
413 message.portNo.write2Bytes(bb);
414 // pad: 2 bytes
415 bb.writeZero(2);
416 bb.writeInt(U32.t(message.queueId));
417 bb.writeLong(message.txBytes.getValue());
418 bb.writeLong(message.txPackets.getValue());
419 bb.writeLong(message.txErrors.getValue());
420
421
422 }
423 }
424
425 @Override
426 public String toString() {
427 StringBuilder b = new StringBuilder("OFQueueStatsEntryVer10(");
428 b.append("portNo=").append(portNo);
429 b.append(", ");
430 b.append("queueId=").append(queueId);
431 b.append(", ");
432 b.append("txBytes=").append(txBytes);
433 b.append(", ");
434 b.append("txPackets=").append(txPackets);
435 b.append(", ");
436 b.append("txErrors=").append(txErrors);
437 b.append(")");
438 return b.toString();
439 }
440
441 @Override
442 public boolean equals(Object obj) {
443 if (this == obj)
444 return true;
445 if (obj == null)
446 return false;
447 if (getClass() != obj.getClass())
448 return false;
449 OFQueueStatsEntryVer10 other = (OFQueueStatsEntryVer10) obj;
450
451 if (portNo == null) {
452 if (other.portNo != null)
453 return false;
454 } else if (!portNo.equals(other.portNo))
455 return false;
456 if( queueId != other.queueId)
457 return false;
458 if (txBytes == null) {
459 if (other.txBytes != null)
460 return false;
461 } else if (!txBytes.equals(other.txBytes))
462 return false;
463 if (txPackets == null) {
464 if (other.txPackets != null)
465 return false;
466 } else if (!txPackets.equals(other.txPackets))
467 return false;
468 if (txErrors == null) {
469 if (other.txErrors != null)
470 return false;
471 } else if (!txErrors.equals(other.txErrors))
472 return false;
473 return true;
474 }
475
476 @Override
477 public int hashCode() {
478 final int prime = 31;
479 int result = 1;
480
481 result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
482 result = prime * (int) (queueId ^ (queueId >>> 32));
483 result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
484 result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
485 result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
486 return result;
487 }
488
489}